Merge lp:~robru/location-service/pre_release_hook into lp:location-service/trunk

Proposed by Robert Bruce Park
Status: Superseded
Proposed branch: lp:~robru/location-service/pre_release_hook
Merge into: lp:location-service/trunk
Diff against target: 3418 lines (+2295/-268)
61 files modified
CMakeLists.txt (+42/-3)
_clang-format (+56/-0)
astyle-config (+43/-0)
debian/VERSION (+1/-0)
debian/VERSION.vivid (+1/-0)
debian/bileto_pre_release_hook (+75/-0)
debian/changelog (+132/-37)
debian/control (+11/-5)
debian/control.in (+123/-0)
debian/get-versions.sh (+68/-0)
debian/libubuntu-location-service-dev.install (+6/-1)
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)
examples/service/service.cpp (+14/-15)
include/location_service/com/ubuntu/location/provider_factory.h (+3/-0)
po/ubuntu-location-service.pot (+7/-11)
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 (+25/-28)
src/location_service/com/ubuntu/location/engine.h (+3/-3)
src/location_service/com/ubuntu/location/provider_factory.cpp (+14/-0)
src/location_service/com/ubuntu/location/providers/config.cpp (+7/-0)
src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt (+3/-1)
src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp (+42/-0)
src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h (+62/-0)
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/providers/remote/provider.cpp (+23/-0)
src/location_service/com/ubuntu/location/service/daemon.cpp (+27/-82)
src/location_service/com/ubuntu/location/service/implementation.cpp (+25/-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/service/trust_store_permission_manager.cpp (+1/-1)
src/location_service/com/ubuntu/location/time_based_update_policy.cpp (+4/-3)
tests/CMakeLists.txt (+2/-0)
tests/acceptance_tests.cpp (+114/-12)
tests/delayed_service_test.cpp (+193/-0)
tests/engine_test.cpp (+4/-13)
tests/gps_provider_test.cpp (+83/-0)
tests/mock_event_receiver.h (+35/-0)
tests/position_test.cpp (+1/-1)
tests/remote_providerd_test.cpp (+1/-7)
tests/runtime_test.cpp (+118/-0)
tools/CMakeLists.txt (+1/-0)
tools/symbol_diff.in (+70/-0)
To merge this branch: bzr merge lp:~robru/location-service/pre_release_hook
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+291016@code.launchpad.net

This proposal has been superseded by a proposal from 2016-04-05.

Commit message

Use new bileto_pre_release_hook.

To post a comment you must log in.
231. By Robert Bruce Park

Simplify symlinks.

232. By Robert Bruce Park

Fix ln.

Unmerged revisions

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-04-05 17:17:30 +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-04-05 17:17:30 +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-04-05 17:17:30 +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-04-05 17:17:30 +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-04-05 17:17:30 +0000
183@@ -0,0 +1,1 @@
184+2.0.0
185
186=== added file 'debian/bileto_pre_release_hook'
187--- debian/bileto_pre_release_hook 1970-01-01 00:00:00 +0000
188+++ debian/bileto_pre_release_hook 2016-04-05 17:17:30 +0000
189@@ -0,0 +1,75 @@
190+#!/bin/sh
191+
192+# Copyright (C) 2015 Canonical Ltd
193+#
194+# This program is free software: you can redistribute it and/or modify
195+# it under the terms of the GNU Lesser General Public License version 3 as
196+# published by the Free Software Foundation.
197+#
198+# This program is distributed in the hope that it will be useful,
199+# but WITHOUT ANY WARRANTY; without even the implied warranty of
200+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201+# GNU Lesser General Public License for more details.
202+#
203+# You should have received a copy of the GNU Lesser General Public License
204+# along with this program. If not, see <http://www.gnu.org/licenses/>.
205+#
206+# Authored by: Michi Henning <michi.henning@canonical.com>
207+# Thomas Voß <thomas.voss@canonical.com>
208+# Robert Bruce Park <robert.park@canonical.com>
209+
210+#
211+# Script to generate debian files for dual landing in Vivid (gcc 4.9 ABI)
212+# and Wily and later (gcc 5 ABI).
213+#
214+# This script is called from debian/rules and generates:
215+#
216+# - control
217+# - libubuntu-location-service${soversion}.install.${target_arch}
218+#
219+# For all but control, this is a straight substition and/or renaming exercise for each file.
220+#
221+
222+set -e # Fail if any command fails.
223+
224+progname=$(basename $0)
225+
226+[ $# -gt 1 ] && {
227+ echo "usage: $progname [path-to-debian-dir]" >&2
228+ exit 1
229+}
230+dir=$1
231+version_dir=$(mktemp -d)
232+
233+[ -n "$dir" ] || dir="./debian"
234+[ -n "$SERIES" ] || SERIES="$(lsb_release -c -s)"
235+
236+# Dump version numbers into files and initialize vars from those files.
237+sh ${dir}/get-versions.sh ${dir} ${version_dir}
238+
239+export UBUNTU_LOCATION_SERVICE_SOVERSION=$(cat $version_dir/libubuntu-location-service.soversion)
240+
241+trap "rm -fr $version_dir" 0 INT TERM QUIT
242+
243+process()
244+{
245+ cat <<EOF
246+# This file is autogenerated. DO NOT EDIT!
247+#
248+# Modifications should be made to $(basename "$1") instead.
249+# This file is regenerated automatically in the clean target.
250+#
251+EOF
252+ perl -pe 's/@([A-Z_]+)@/$ENV{$1} or die "$1 undefined"/eg' <"$1"
253+}
254+
255+process "$dir/control.in" >"$dir/control"
256+process "$dir/libubuntu-location-service.install.in" >"$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install"
257+process "$dir/libubuntu-location-service.install.with-gps.in" >"$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.with-gps"
258+process "$dir/libubuntu-location-service-dev.install.in" >"$dir/libubuntu-location-service-dev.install"
259+
260+ln -s "$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.with-gps" "$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.amd64"
261+ln -s "$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.with-gps" "$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.armhf"
262+ln -s "$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.with-gps" "$dir/libubuntu-location-service${UBUNTU_LOCATION_SERVICE_SOVERSION}.install.i386"
263+
264+exit 0
265
266=== modified file 'debian/changelog'
267--- debian/changelog 2015-07-27 18:07:37 +0000
268+++ debian/changelog 2016-04-05 17:17:30 +0000
269@@ -1,40 +1,135 @@
270-location-service (2.1+15.10.20150727-0ubuntu1) wily; urgency=medium
271-
272- [ CI Train Bot ]
273- * New rebuild forced.
274-
275- [ Charles Kerr ]
276- * drop build-dependency on g++-4.9 (LP: #1452329)
277-
278- -- CI Train Bot <ci-train-bot@canonical.com> Mon, 27 Jul 2015 18:07:37 +0000
279-
280-location-service (2.1+15.10.20150706-0ubuntu1) wily; urgency=medium
281-
282- [ Alberto Aguirre ]
283- * No change rebuild against platform-api 3
284-
285- [ CI Train Bot ]
286- * New rebuild forced.
287-
288- -- CI Train Bot <ci-train-bot@canonical.com> Mon, 06 Jul 2015 18:22:22 +0000
289-
290-location-service (2.1+15.10.20150601.2-0ubuntu1) wily; urgency=medium
291-
292- [ CI Train Bot ]
293- * New rebuild forced.
294-
295- [ Manuel de la Pena ]
296- * Ensure that the trust store is started when is needed.
297-
298- -- CI Train Bot <ci-train-bot@canonical.com> Mon, 01 Jun 2015 15:13:06 +0000
299-
300-location-service (2.1+15.10.20150528.3-0ubuntu1) wily; urgency=medium
301-
302- [ Thomas Voß ]
303- * Make sure we always hand a lock owning its mutex to
304- on_access_point_added. (LP: #1426307)
305-
306- -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +0000
307+location-service (3.0.0-0ubuntu5) UNRELEASED; urgency=medium
308+
309+ * Enable dual landings according to https://wiki.ubuntu.com/citrain/LandingProcess#Dual-landing_for_stable_and_devel:
310+ * Both vivid+overlay and xenial packages are built from the same
311+ source.
312+ * To account for differences in major revisions (necessary to handle
313+ the g++ 5 ABI break), we generate install files on the fly.
314+
315+ -- Thomas Voß <thomas.voss@canonical.com> Wed, 16 Mar 2016 20:15:57 +0100
316+
317+location-service (3.0.0-0ubuntu4) wily-proposed; urgency=medium
318+
319+ * No change rebuild.
320+
321+ -- Ken VanDine <ken.vandine@canonical.com> Mon, 03 Aug 2015 13:33:13 -0400
322+
323+location-service (3.0.0-0ubuntu3) wily; urgency=medium
324+
325+ * No change rebuild.
326+
327+ -- Matthias Klose <doko@ubuntu.com> Fri, 31 Jul 2015 00:23:18 +0200
328+
329+location-service (3.0.0-0ubuntu2) wily; urgency=medium
330+
331+ * libubuntu-location-service3: Replaces libubuntu-location-service2,
332+ config file /etc/gps.conf in both packages.
333+
334+ -- Matthias Klose <doko@ubuntu.com> Thu, 30 Jul 2015 09:57:50 +0200
335+
336+location-service (3.0.0) wily; urgency=medium
337+
338+ * Bump major revision and fix LP:#1478750 to account for toolchain update.
339+
340+ -- Thomas Voß <thomas.voss@canonical.com> Thu, 30 Jul 2015 08:33:13 +0200
341+
342+location-service (2.1+15.04.20160302.1-0ubuntu1) vivid; urgency=medium
343+
344+ * Remove explicit option to disable satellite-based positioning
345+ services.
346+
347+ -- Thomas Voß <ci-train-bot@canonical.com> Wed, 02 Mar 2016 15:28:02 +0000
348+
349+location-service (2.1+15.04.20160106-0ubuntu1) vivid; urgency=medium
350+
351+ [ Alberto Mardegan ]
352+ * Set debian source format to "3.0 (native)"
353+
354+ [ Scott Sweeny ]
355+ * Allow providers to register themselves asynchronously (LP: #1415029)
356+
357+ -- Thomas Voß <ci-train-bot@canonical.com> Wed, 06 Jan 2016 16:15:29 +0000
358+
359+location-service (2.1+15.04.20151211-0ubuntu1) vivid; urgency=medium
360+
361+ * Account for changes in trust-store w.r.t. assembling the description
362+ of a trust prompt.
363+
364+ -- Thomas Voß <ci-train-bot@canonical.com> Fri, 11 Dec 2015 08:57:44 +0000
365+
366+location-service (2.1+15.04.20151209-0ubuntu1) vivid; urgency=medium
367+
368+ * Fix settings not being applied correctly.
369+
370+ -- Thomas Voß <ci-train-bot@canonical.com> Wed, 09 Dec 2015 15:22:22 +0000
371+
372+location-service (2.1+15.04.20151202.1-0ubuntu1) vivid; urgency=medium
373+
374+ * Ensure that event connections are cleaned up on destruction. (LP:
375+ #1480877)
376+
377+ -- Thomas Voß <ci-train-bot@canonical.com> Wed, 02 Dec 2015 12:12:21 +0000
378+
379+location-service (2.1+15.04.20151127-0ubuntu1) vivid; urgency=medium
380+
381+ [ Alberto Mardegan ]
382+ * Send last known position on session start
383+
384+ [ CI Train Bot ]
385+ * New rebuild forced.
386+
387+ [ Thomas Voß ]
388+ * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
389+ pair of files. Add test cases around correct operation of
390+ service::Runtime. added:
391+ src/location_service/com/ubuntu/location/service/runtime.cpp
392+ src/location_service/com/ubuntu/location/service/runtime.h
393+ tests/runtime_test.cpp
394+
395+ [ thomas-voss ]
396+ * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
397+ pair of files. Add test cases around correct operation of
398+ service::Runtime. added:
399+ src/location_service/com/ubuntu/location/service/runtime.cpp
400+ src/location_service/com/ubuntu/location/service/runtime.h
401+ tests/runtime_test.cpp
402+
403+ -- Thomas Voß <ci-train-bot@canonical.com> Fri, 27 Nov 2015 13:00:33 +0000
404+
405+location-service (2.1+15.04.20151113-0ubuntu1) vivid; urgency=medium
406+
407+ * Adjust default timeout for downloading GPS XTRA data.
408+
409+ -- Thomas Voß <ci-train-bot@canonical.com> Fri, 13 Nov 2015 10:33:56 +0000
410+
411+location-service (2.1+15.04.20151109.2-0ubuntu1) vivid; urgency=medium
412+
413+ [ Alberto Mardegan ]
414+ * Make sure that injected time is given in milliseconds
415+
416+ [ Thomas Voß ]
417+ * Cherry-pick rev. 196 and 199 from lp:location-service. The changes
418+ got accidentally removed by merging the outstanding documentation
419+ branch.
420+ * Handle responses of clients to updates asynchronously. Rely on
421+ dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
422+ #1462664, #1387643)
423+
424+ -- David Barth <david.barth@canonical.com> Mon, 09 Nov 2015 20:48:48 +0000
425+
426+location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium
427+
428+ [ Thomas Voß ]
429+ * Add documentation for debugging, hacking and debugging the location
430+ service. Pull manual testing instructions over from the wiki. Add
431+ tools for formatting the source.
432+
433+ [ thomas-voss ]
434+ * Add documentation for debugging, hacking and debugging the location
435+ service. Pull manual testing instructions over from the wiki. Add
436+ tools for formatting the source.
437+
438+ -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000
439
440 location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium
441
442
443=== modified file 'debian/control'
444--- debian/control 2015-07-15 19:04:43 +0000
445+++ debian/control 2016-04-05 17:17:30 +0000
446@@ -1,3 +1,8 @@
447+# This file is autogenerated. DO NOT EDIT!
448+#
449+# Modifications should be made to control.in instead.
450+# This file is regenerated automatically in the clean target.
451+#
452 Source: location-service
453 Section: utils
454 Priority: optional
455@@ -27,6 +32,7 @@
456 libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],
457 libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],
458 libproperties-cpp-dev,
459+ lsb-release,
460 trust-store-bin,
461 Standards-Version: 3.9.4
462 Homepage: http://launchpad.net/location-service
463@@ -35,7 +41,7 @@
464 Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk
465 Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files
466
467-Package: libubuntu-location-service2
468+Package: libubuntu-location-service3
469 Section: libs
470 Architecture: any
471 Multi-Arch: same
472@@ -52,7 +58,7 @@
473 Architecture: any
474 Multi-Arch: foreign
475 Recommends: ubuntu-location-service-doc,
476-Depends: libubuntu-location-service2 (= ${binary:Version}),
477+Depends: libubuntu-location-service3 (= ${binary:Version}),
478 libdbus-1-dev,
479 libdbus-cpp-dev,
480 libboost-dev,
481@@ -68,7 +74,7 @@
482 Section: debug
483 Architecture: any
484 Multi-Arch: foreign
485-Depends: libubuntu-location-service2 (= ${binary:Version}),
486+Depends: libubuntu-location-service3 (= ${binary:Version}),
487 ${misc:Depends},
488 Description: location service aggregating position/velocity/heading
489 updates and exporting them over dbus.
490@@ -86,7 +92,7 @@
491
492 Package: ubuntu-location-service-bin
493 Architecture: any
494-Depends: libubuntu-location-service2 (= ${binary:Version}),
495+Depends: libubuntu-location-service3 (= ${binary:Version}),
496 ${misc:Depends},
497 ${shlibs:Depends},
498 trust-store-bin,
499@@ -100,7 +106,7 @@
500 Package: ubuntu-location-service-examples
501 Architecture: any
502 Multi-Arch: same
503-Depends: libubuntu-location-service2 (= ${binary:Version}),
504+Depends: libubuntu-location-service3 (= ${binary:Version}),
505 ${misc:Depends},
506 ${shlibs:Depends},
507 ubuntu-location-service-doc,
508
509=== added file 'debian/control.in'
510--- debian/control.in 1970-01-01 00:00:00 +0000
511+++ debian/control.in 2016-04-05 17:17:30 +0000
512@@ -0,0 +1,123 @@
513+Source: location-service
514+Section: utils
515+Priority: optional
516+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
517+XSBC-Original-Maintainer: Thomas Voß <thomas.voss@canonical.com>
518+Build-Depends: cmake,
519+ curl,
520+ libdbus-cpp-dev (>= 4.1.0),
521+ debhelper (>= 9),
522+ doxygen,
523+ geoclue-ubuntu-geoip,
524+ google-mock (>= 1.6.0+svn437),
525+ graphviz,
526+ libapparmor-dev,
527+ libboost-filesystem-dev,
528+ libboost-program-options-dev,
529+ libboost-system-dev,
530+ libdbus-1-dev,
531+ libdbus-cpp-dev,
532+ libgoogle-glog-dev,
533+ libgtest-dev,
534+ libiw-dev,
535+ libjson-c-dev,
536+ libnet-cpp-dev,
537+ libprocess-cpp-dev,
538+ libtrust-store-dev,
539+ libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],
540+ libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],
541+ libproperties-cpp-dev,
542+ lsb-release,
543+ trust-store-bin,
544+Standards-Version: 3.9.4
545+Homepage: http://launchpad.net/location-service
546+# If you aren't a member of ~phablet-team but need to upload packaging changes,
547+# just go ahead. ~phablet-team will notice and sync up the code again.
548+Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk
549+Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files
550+
551+Package: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@
552+Section: libs
553+Architecture: any
554+Multi-Arch: same
555+Pre-Depends: ${misc:Pre-Depends}
556+Depends: ${misc:Depends},
557+ ${shlibs:Depends},
558+Description: location service aggregating position/velocity/heading
559+ updates and exporting them over dbus.
560+ .
561+ Contains the shared library needed by client applications.
562+
563+Package: libubuntu-location-service-dev
564+Section: libdevel
565+Architecture: any
566+Multi-Arch: foreign
567+Recommends: ubuntu-location-service-doc,
568+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
569+ libdbus-1-dev,
570+ libdbus-cpp-dev,
571+ libboost-dev,
572+ ${misc:Depends},
573+Suggests: ubuntu-location-service-doc,
574+Description: location service aggregating position/velocity/heading
575+ updates and exporting them over dbus.
576+ .
577+ Contains header files required to develop clients talking to the ubuntu
578+ location service.
579+
580+Package: libubuntu-location-service-dbg
581+Section: debug
582+Architecture: any
583+Multi-Arch: foreign
584+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
585+ ${misc:Depends},
586+Description: location service aggregating position/velocity/heading
587+ updates and exporting them over dbus.
588+ .
589+ Contains debug symbols.
590+
591+Package: ubuntu-location-service-tests
592+Architecture: any
593+Depends: ${misc:Depends},
594+ ${shlibs:Depends},
595+Description: location service aggregating position/velocity/heading
596+ updates and exporting them over dbus.
597+ .
598+ Contains all test executables
599+
600+Package: ubuntu-location-service-bin
601+Architecture: any
602+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
603+ ${misc:Depends},
604+ ${shlibs:Depends},
605+ trust-store-bin,
606+Breaks: ubuntu-location-service-examples (<< 0.0.2),
607+Replaces: ubuntu-location-service-examples (<< 0.0.2),
608+Description: location service aggregating position/velocity/heading
609+ updates and exporting them over dbus.
610+ .
611+ Contains the service executable and man pages.
612+
613+Package: ubuntu-location-service-examples
614+Architecture: any
615+Multi-Arch: same
616+Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
617+ ${misc:Depends},
618+ ${shlibs:Depends},
619+ ubuntu-location-service-doc,
620+Description: location service aggregating position/velocity/heading
621+ updates and exporting them over dbus.
622+ .
623+ Contains example service and client.
624+
625+Package: ubuntu-location-service-doc
626+Section: doc
627+Architecture: all
628+Multi-Arch: foreign
629+Depends: ${misc:Depends},
630+ ${shlibs:Depends},
631+Recommends: ubuntu-location-service-examples,
632+Description: location service aggregating position/velocity/heading
633+ updates and exporting them over dbus.
634+ .
635+ Contains documentation for service and client.
636
637=== added file 'debian/get-versions.sh'
638--- debian/get-versions.sh 1970-01-01 00:00:00 +0000
639+++ debian/get-versions.sh 2016-04-05 17:17:30 +0000
640@@ -0,0 +1,68 @@
641+#!/bin/sh
642+
643+# Copyright (C) 2015 Canonical Ltd
644+#
645+# This program is free software: you can redistribute it and/or modify
646+# it under the terms of the GNU Lesser General Public License version 3 as
647+# published by the Free Software Foundation.
648+#
649+# This program is distributed in the hope that it will be useful,
650+# but WITHOUT ANY WARRANTY; without even the implied warranty of
651+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
652+# GNU Lesser General Public License for more details.
653+#
654+# You should have received a copy of the GNU Lesser General Public License
655+# along with this program. If not, see <http://www.gnu.org/licenses/>.
656+#
657+# Authored by: Michi Henning <michi.henning@canonical.com>
658+
659+#
660+# Script to read the version numbers from VERSION and QT-VERSION
661+# and write the version components and the soversion numbers
662+# into separate files, so we can pick them up from both
663+# gen-debian-files.sh and CMakeLists.txt.
664+#
665+
666+set -e # Fail if any command fails.
667+
668+progname=$(basename $0)
669+
670+[ $# -lt 1 -o $# -gt 2 ] && {
671+ echo "usage: $progname path-to-debian-dir [output-dir]" >&2
672+ exit 1
673+}
674+dir=$1
675+output_dir=`pwd`
676+[ $# -eq 2 ] && output_dir=$2
677+
678+# Write the various version numbers into a bunch of files. This allows
679+# us to easily pick them up from both bileto_pre_release_hook and CMakeLists.txt.
680+
681+[ -n "$SERIES" ] || SERIES="$(lsb_release -c -s)"
682+
683+full_version=$(cat "${dir}"/VERSION)
684+
685+major=$(echo $full_version | cut -d'.' -f1)
686+minor=$(echo $full_version | cut -d'.' -f2)
687+micro=$(echo $full_version | cut -d'.' -f3)
688+major_minor="${major}.${minor}"
689+
690+vivid_full_version=$(cat "${dir}"/VERSION.vivid)
691+vivid_major=$(echo $vivid_full_version | cut -d'.' -f1)
692+vivid_soversion=$vivid_major
693+
694+if [ "$SERIES" = "vivid" ]
695+then
696+ soversion=${vivid_soversion}
697+else
698+ soversion="${major}"
699+fi
700+[ -n "$soversion" ]
701+
702+echo ${full_version} >${output_dir}/libubuntu-location-service.full-version
703+echo ${major} >${output_dir}/libubuntu-location-service.major-version
704+echo ${minor} >${output_dir}/libubuntu-location-service.minor-version
705+echo ${micro} >${output_dir}/libubuntu-location-service.micro-version
706+echo ${major_minor} >${output_dir}/libubuntu-location-service.major-minor-version
707+echo ${soversion} >${output_dir}/libubuntu-location-service.soversion
708+echo ${vivid_soversion} >${output_dir}/libubuntu-location-service.vivid-soversion
709
710=== modified file 'debian/libubuntu-location-service-dev.install'
711--- debian/libubuntu-location-service-dev.install 2014-07-18 14:42:10 +0000
712+++ debian/libubuntu-location-service-dev.install 2016-04-05 17:17:30 +0000
713@@ -1,4 +1,9 @@
714-usr/include/ubuntu-location-service-2
715+# This file is autogenerated. DO NOT EDIT!
716+#
717+# Modifications should be made to libubuntu-location-service-dev.install.in instead.
718+# This file is regenerated automatically in the clean target.
719+#
720+usr/include/ubuntu-location-service-3
721 usr/lib/*/libubuntu-location-service.so
722 usr/lib/*/libubuntu-location-service-connectivity.so
723 usr/lib/*/pkgconfig/ubuntu-location-service.pc
724
725=== added file 'debian/libubuntu-location-service-dev.install.in'
726--- debian/libubuntu-location-service-dev.install.in 1970-01-01 00:00:00 +0000
727+++ debian/libubuntu-location-service-dev.install.in 2016-04-05 17:17:30 +0000
728@@ -0,0 +1,5 @@
729+usr/include/ubuntu-location-service-@UBUNTU_LOCATION_SERVICE_SOVERSION@
730+usr/lib/*/libubuntu-location-service.so
731+usr/lib/*/libubuntu-location-service-connectivity.so
732+usr/lib/*/pkgconfig/ubuntu-location-service.pc
733+usr/lib/*/pkgconfig/ubuntu-location-service-connectivity.pc
734
735=== added file 'debian/libubuntu-location-service.install.in'
736--- debian/libubuntu-location-service.install.in 1970-01-01 00:00:00 +0000
737+++ debian/libubuntu-location-service.install.in 2016-04-05 17:17:30 +0000
738@@ -0,0 +1,2 @@
739+usr/lib/*/libubuntu-location-service.so.*
740+usr/lib/*/libubuntu-location-service-connectivity.so.*
741
742=== added file 'debian/libubuntu-location-service.install.with-gps.in'
743--- debian/libubuntu-location-service.install.with-gps.in 1970-01-01 00:00:00 +0000
744+++ debian/libubuntu-location-service.install.with-gps.in 2016-04-05 17:17:30 +0000
745@@ -0,0 +1,3 @@
746+usr/lib/*/libubuntu-location-service.so.*
747+usr/lib/*/libubuntu-location-service-connectivity.so.*
748+/etc/gps.conf
749
750=== removed file 'debian/libubuntu-location-service2.install'
751--- debian/libubuntu-location-service2.install 2014-07-30 13:55:44 +0000
752+++ debian/libubuntu-location-service2.install 1970-01-01 00:00:00 +0000
753@@ -1,2 +0,0 @@
754-usr/lib/*/libubuntu-location-service.so.*
755-usr/lib/*/libubuntu-location-service-connectivity.so.*
756
757=== removed symlink 'debian/libubuntu-location-service2.install.amd64'
758=== target was u'libubuntu-location-service2.install.with-gps'
759=== removed symlink 'debian/libubuntu-location-service2.install.armhf'
760=== target was u'libubuntu-location-service2.install.with-gps'
761=== removed symlink 'debian/libubuntu-location-service2.install.i386'
762=== target was u'libubuntu-location-service2.install.with-gps'
763=== removed file 'debian/libubuntu-location-service2.install.with-gps'
764--- debian/libubuntu-location-service2.install.with-gps 2014-07-30 13:55:44 +0000
765+++ debian/libubuntu-location-service2.install.with-gps 1970-01-01 00:00:00 +0000
766@@ -1,3 +0,0 @@
767-usr/lib/*/libubuntu-location-service.so.*
768-usr/lib/*/libubuntu-location-service-connectivity.so.*
769-/etc/gps.conf
770
771=== modified file 'debian/rules'
772--- debian/rules 2015-07-15 19:04:43 +0000
773+++ debian/rules 2016-04-05 17:17:30 +0000
774@@ -15,6 +15,18 @@
775
776 include /usr/share/dpkg/default.mk
777
778+distro=$(shell lsb_release -c -s)
779+
780+ifeq ($(distro),vivid)
781+ full_version=$(shell cat $(CURDIR)/debian/VERSION.vivid)
782+else
783+ full_version=$(shell cat $(CURDIR)/debian/VERSION)
784+endif
785+
786+major=$(shell echo $(full_version) | cut -d'.' -f1)
787+minor=$(shell echo $(full_version) | cut -d'.' -f2)
788+patch=$(shell echo $(full_version) | cut -d'.' -f3)
789+
790 ifneq (,$(filter $(DEB_HOST_ARCH),ppc64el powerpc arm64))
791 LOCATION_SERVICE_ENABLE_GPS_PROVIDER = OFF
792 else
793@@ -31,4 +43,11 @@
794 dh_strip --dbg-package=libubuntu-location-service-dbg
795
796 override_dh_auto_configure:
797- 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)
798+ 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)
799+
800+override_dh_auto_clean:
801+ rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.amd64
802+ rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.armhf
803+ rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.i386
804+ /bin/sh $(CURDIR)/debian/bileto_pre_release_hook
805+ dh_auto_clean
806
807=== modified file 'debian/source/format'
808--- debian/source/format 2014-07-30 14:15:06 +0000
809+++ debian/source/format 2016-04-05 17:17:30 +0000
810@@ -1,1 +1,1 @@
811-3.0 (quilt)
812+3.0 (native)
813
814=== modified file 'doc/Doxyfile.in'
815--- doc/Doxyfile.in 2014-05-19 09:55:25 +0000
816+++ doc/Doxyfile.in 2016-04-05 17:17:30 +0000
817@@ -748,7 +748,7 @@
818 # directories that contain image that are included in the documentation (see
819 # the \image command).
820
821-IMAGE_PATH =
822+IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images
823
824 # The INPUT_FILTER tag can be used to specify a program that doxygen should
825 # invoke to filter for each input file. Doxygen will invoke the filter program
826@@ -1463,7 +1463,7 @@
827 # generate an XML file that captures the structure of
828 # the code including all documentation.
829
830-GENERATE_XML = NO
831+GENERATE_XML = YES
832
833 # The XML_OUTPUT tag is used to specify where the XML pages will be put.
834 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
835
836=== added file 'doc/daemon_and_cli.md'
837--- doc/daemon_and_cli.md 1970-01-01 00:00:00 +0000
838+++ doc/daemon_and_cli.md 2016-04-05 17:17:30 +0000
839@@ -0,0 +1,55 @@
840+# Service Daemon and CLI
841+
842+The location service offers a daemon executable and a corresponding
843+command-line interface for interacting with it. The daemon does not
844+necessarily require root privileges, but might so depending on your
845+configuration.
846+
847+Run the following command to receive an overview of the arguments to
848+the daemon:
849+
850+ ubuntu-location-serviced --help
851+
852+An example invocation of the daemon, configuring a GPS provider that
853+relies on the Android HAL to talk to the chipset, exposing the service
854+on the system DBus instance:
855+
856+ ubuntu-location-serviced --bus system --provider gps::Provider
857+
858+The cli allows for querying properties of a running service instance, e.g.:
859+
860+ ubuntu-location-serviced-cli --bus system --get --property is_online
861+
862+## Configuring an Out-Of-Process Provider
863+
864+If you want to run a provider out of process, the daemon executable
865+allows you to do so by instantiating a so-called remote provider. The
866+following invocation of the service tries to connect to the provider
867+instance described by the given unique DBus name and path.
868+
869+ ubuntu-location-serviced \
870+ --bus system \
871+ --provider remote::Provider \
872+ --remote::Provider::bus=system \
873+ --remote::Provider::name=com.ubuntu.location.provider.Gps \
874+ --remote::Provider::path=/
875+
876+Please note that the service allows for decorating provider names to
877+uniquely identify per provider configuration options and to allow for
878+loading more than one provider of a certain kind. The following
879+configuration configures two remote providers, one relying on GPS
880+(decorated with @gps) and another one relying on network-based
881+positioning (decorated with @network):
882+
883+ ubuntu-location-serviced \
884+ --bus system \
885+ --provider remote::Provider@gps \
886+ --remote::Provider@gps::bus=system \
887+ --remote::Provider@gps::name=com.ubuntu.location.provider.Gps \
888+ --remote::Provider@gps::path=/ \
889+ --provider remote::Provider@network \
890+ --remote::Provider@network::bus=system \
891+ --remote::Provider@network::name=com.ubuntu.location.provider.Network \
892+ --remote::Provider@network::path=/
893+
894+
895
896=== added file 'doc/debugging.md'
897--- doc/debugging.md 1970-01-01 00:00:00 +0000
898+++ doc/debugging.md 2016-04-05 17:17:30 +0000
899@@ -0,0 +1,92 @@
900+# Debugging
901+
902+Location not working? Here's how to debug.
903+
904+## Layers
905+
906+Test in OSMTouch (QML app using Qt API) before testing in webapps or
907+webbrowser app. Different results? File a bug where it doesn't
908+work. Same result of no location? Next step.
909+
910+## Check that stack works with dummy provider
911+
912+Edit /etc/init/ubuntu-location-provider.override to start
913+location-serviced with just the dummy provider; this should
914+work. Doesn't work? File a bug against location-service. Works? Reset
915+config to defaults and try the next thing.
916+
917+## Hardware GPS breaking all of location-service
918+
919+GPS provider is built-in into location-service and might break all of
920+it if it goes south (working on splitting it out); try enabling only
921+the HERE provider on the location-serviced command-line and see if
922+that works. Works? File a bug against location-service. Doesn't work?
923+Move on.
924+
925+## HERE test
926+
927+To test whether the low-level HERE stack gets a location, put
928+http://people.canonical.com/~lool/espoo-cli on your phone (will be
929+included along HERE bits in the future) and run with:
930+
931+ chmod a+x espoo-cli
932+ GLOG_logtostderr=1 GLOG_v=100 LD_LIBRARY_PATH=/custom/vendor/here/location-provider/lib/arm-linux-gnueabihf ./espoo-cli 5
933+
934+NB: 5 is the number of location updates after which the tool exits;
935+updates should come in at approx 15s interval. Output looks like:
936+
937+ I1101 21:30:01.285964 4403 cli.cpp:117] Requested number of updates is 2
938+ I1101 21:30:01.299002 4403 cli.cpp:133] Starting location updates
939+ I1101 21:30:01.301888 4403 cli.cpp:141] Starting GLib main loop
940+ 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
941+ I1101 21:30:11.306061 4403 cli.cpp:170] Remaining updates: 1
942+ 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
943+ I1101 21:30:26.738348 4403 cli.cpp:148] Stopping location updates
944+
945+Low-level HERE stack works but location-serviced with just HERE
946+provider doesn't work? File a bug against espoo projet (HERE) and/or
947+location-service. Low-level HERE stack doesn't work? Move on
948+
949+## location-service and espoo-service debug
950+
951+Collect some debug data by editing /etc/init/ubuntu-espoo-service.conf
952+and /etc/init/ubuntu-location-service.override and changing the start
953+sequence to add some env vars:
954+
955+ export GLOG_v=200
956+ export GLOG_logtostderr=1
957+
958+before the exec. Reboot, and start some app. You should have some log
959+files under /var/log/upstart/ubuntu-espoo-service.log and
960+/var/log/upstart/ubuntu-location-service.log to attach to a bug
961+report; e.g. a working espoo log looks like this:
962+
963+ WARNING: Logging before InitGoogleLogging() is written to STDERR
964+ I1105 16:30:10.221474 1620 provider.cpp:568] StartPositionUpdates
965+ I1105 16:30:10.224901 1620 provider.cpp:122] Successfully started position updates.
966+ I1105 16:30:10.228739 1620 provider.cpp:596] StartVelocityUpdates
967+ 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)
968+
969+No position there? check connectivity API works by running:
970+
971+ cd /tmp
972+ wget http://people.ubuntu.com/~lool/connectivity
973+ GLOG_v=200 GLOG_logtostderr=1 ./connectivity
974+
975+you should see something like:
976+
977+ I1105 16:47:26.431466 11140 cached_radio_cell.cpp:160] (mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
978+ I1105 16:47:26.533818 11140 connectivity.cpp:47] Is wifi enabled: true
979+ I1105 16:47:26.533963 11140 connectivity.cpp:48] Is wifi hw enabled: true
980+ I1105 16:47:26.534010 11140 connectivity.cpp:49] Is wwan enabled: true
981+ I1105 16:47:26.534050 11140 connectivity.cpp:50] Is wwan hw enabled: true
982+ I1105 16:47:26.534442 11140 connectivity.cpp:122] umts(mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
983+ 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)
984+ 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)
985+
986+Also, please attach output of /usr/share/ofono/scripts/list-modems > list-modems-output.txt
987+Please note that the command might take ~1 minute to complete.
988+
989+TODO: document dbus-monitor / d-feet capturing of client / system traffic with snooping config.
990+
991+
992
993=== added file 'doc/hacking.md'
994--- doc/hacking.md 1970-01-01 00:00:00 +0000
995+++ doc/hacking.md 2016-04-05 17:17:30 +0000
996@@ -0,0 +1,146 @@
997+# Hacking
998+
999+
1000+## Building the code
1001+
1002+By default, the code is built in release mode. To build a debug version, use
1003+
1004+ $ mkdir builddebug
1005+ $ cd builddebug
1006+ $ cmake -DCMAKE_BUILD_TYPE=debug ..
1007+ $ make
1008+
1009+For a release version, use -DCMAKE_BUILD_TYPE=release
1010+
1011+## Running the tests
1012+
1013+ $ make
1014+ $ make test
1015+
1016+Note that "make test" alone is dangerous because it does not rebuild
1017+any tests if either the library or the test files themselves need
1018+rebuilding. It's not possible to fix this with cmake because cmake cannot
1019+add build dependencies to built-in targets. To make sure that everything
1020+is up-to-date, run "make" before running "make test"!
1021+
1022+## Coverage
1023+
1024+To build with the flags for coverage testing enabled and get coverage:
1025+
1026+ $ mkdir buildcoverage
1027+ $ cd buildcoverage
1028+ $ cmake -DCMAKE_BUILD_TYPE=coverage
1029+ $ make
1030+ $ make test
1031+ $ make coverage
1032+
1033+Unfortunately, it is not possible to get 100% coverage for some files,
1034+mainly due to gcc's generation of two destructors for dynamic and non-
1035+dynamic instances. For abstract base classes and for classes that
1036+prevent stack and static allocation, this causes one of the destructors
1037+to be reported as uncovered.
1038+
1039+There are also issues with some functions in header files that are
1040+incorrectly reported as uncovered due to inlining, as well as
1041+the impossibility of covering defensive assert(false) statements,
1042+such as an assert in the default branch of a switch, where the
1043+switch is meant to handle all possible cases explicitly.
1044+
1045+If you run a binary and get lots of warnings about a "merge mismatch for summaries",
1046+this is caused by having made changes to the source that add or remove code
1047+that was previously run, so the new coverage output cannot sensibly be merged
1048+into the old coverage output. You can get rid of this problem by running
1049+
1050+ $ make clean-coverage
1051+
1052+This deletes all the .gcda files, allowing the merge to (sometimes) succeed again.
1053+If this doesn't work either, the only remedy is to do a clean build.
1054+
1055+If lcov complains about unrecognized lines involving '=====',
1056+you can patch geninfo and gcovr as explained here:
1057+
1058+https://bugs.launchpad.net/gcovr/+bug/1086695/comments/2
1059+
1060+## Code style
1061+
1062+We use a format tool that fixes a whole lot of issues
1063+regarding code style. The formatting changes made by
1064+the tool are generally sensible (even though they may not be your
1065+personal preference in all cases). If there is a case where the formatting
1066+really messes things up, consider re-arranging the code to avoid the problem.
1067+The convenience of running the entire code base through the pretty-printer
1068+far outweighs any minor glitches with pretty printing, and it means that
1069+we get consistent code style for free, rather than endlessly having to
1070+watch out for formatting issues during code reviews.
1071+
1072+As of clang-format-3.7, you can use
1073+
1074+ // clang-format off
1075+ void unformatted_code ;
1076+ // clang-format on
1077+
1078+to suppress formatting for a section of code.
1079+
1080+To format specific files:
1081+
1082+ ${CMAKE_BINARY_DIR}/tools/formatcode x.cpp x.h
1083+
1084+If no arguments are provided, formatcode reads stdin and writes
1085+stdout, so you can easily pipe code into the tool from within an
1086+editor. For example, to reformat the entire file in vi (assuming
1087+${CMAKE_BINARY_DIR}/tools is in your PATH):
1088+
1089+ 1G!Gformatcode
1090+
1091+To re-format all source and header files in the tree:
1092+
1093+ $ make formatcode
1094+
1095+## Thread and address sanitizer
1096+
1097+Set SANITIZER to "thread" or "address" to build with the
1098+corresponding sanitizer enabled.
1099+
1100+## Updating symbols file
1101+
1102+To easily spot new/removed/changed symbols in the library, the debian
1103+package maintains a .symbols file that lists all exported symbols
1104+present in the library .so. If you add new public symbols to the library,
1105+it's necessary to refresh the symbols file, otherwise the package will
1106+fail to build. The easiest way to do that is using bzr-builddeb:
1107+
1108+ $ bzr bd -- -us -uc -j8 # Don't sign source package or changes file, 8 compiles in parallel
1109+ $ # this will exit with an error if symbols file isn't up-to-date
1110+ $ cd ../build-area/location-service-[version]
1111+ $ ./obj-[arch]/tools/symbol_diff
1112+
1113+This creates a diff of the symbols in /tmp/symbols.diff.
1114+(The demangled symbols from the debian build are in ./new_symbols.)
1115+
1116+Review any changes in /tmp/symbols.diff. If they are OK:
1117+
1118+ $ cd -
1119+ $ patch -p0 < /tmp/symbols.diff
1120+
1121+## ABI compliance test
1122+
1123+To use this, install abi-compliance-checker package from the archives.
1124+
1125+You can use abi-compliance-checker to test whether a particular build
1126+is ABI compatible with another build. The tool does some source-level
1127+analysis in addition to checking library symbols, so it catches things
1128+that are potentially dangerous, but won't be picked up by just looking
1129+at the symbol table.
1130+
1131+Assume you have built devel in src/devel, and you have a later build
1132+in src/mybranch and want to check that mybranch is still compatible.
1133+To run the compliance test:
1134+
1135+ $ cd src
1136+ $ abi-compliance-checker -lib libunity-scopes.so -old devel/build/test/abi-compliance/abi.xml -new mybranch/build/test/abi-compliance/abi.xml
1137+
1138+The script will take about two minutes to run. Now point your browser at
1139+
1140+ src/compat_reports/libunity-scopes.so/[version]_to_[version]/compat_report.html
1141+
1142+The report provides a nicely layed-out page with all the details.
1143
1144=== added directory 'doc/images'
1145=== added file 'doc/images/LocationServiceHighLevel.png'
1146Binary files doc/images/LocationServiceHighLevel.png 1970-01-01 00:00:00 +0000 and doc/images/LocationServiceHighLevel.png 2016-04-05 17:17:30 +0000 differ
1147=== added file 'doc/intro.md'
1148--- doc/intro.md 1970-01-01 00:00:00 +0000
1149+++ doc/intro.md 2016-04-05 17:17:30 +0000
1150@@ -0,0 +1,67 @@
1151+# Introduction {#mainpage}
1152+
1153+Ubuntu's location service is a central hub for multiplexing access to
1154+positioning subsystems available via hard- and software. It provides a
1155+client API offering positioning capabilities to applications and other
1156+system components, abstracting away the details of individual
1157+positioning solutions.
1158+
1159+## Vocabulary
1160+
1161+To make the remainder of this documentation as easily understandable
1162+as possible, we start over with introducing some vocabulary:
1163+
1164+- Engine:
1165+ Responsible for handling input from multiple positioning
1166+ subsystems and maintaining the state of the overall system. Think
1167+ about it like the heart of the system.
1168+
1169+- Provider:
1170+ A positioning subsystem that feeds into the positioning
1171+ engine. Common examples are a GPS provider or a network-based
1172+ positioning provider.
1173+
1174+- Service:
1175+ The point of entry for applications and services that would
1176+ like to receive position data.
1177+
1178+- Session:
1179+ In order to receive position information, every application
1180+ or service has to create a session with the location Service.
1181+
1182+- Update: An update is a timestamped entity to a certain type of data.
1183+
1184+- [WGS84, http://en.wikipedia.org/wiki/World_Geodetic_System]: The coordinate system that is used throughout the entire location subsystem.
1185+
1186+## Architectural Overview
1187+
1188+The high-level architecture of the service is shown in the following diagram:
1189+
1190+![High-level architectural overview](images/LocationServiceHighLevel.png)
1191+
1192+In this diagram, the configuration of the engine refers to:
1193+
1194+ * The current state of any satellite-based positioning subsystems. Can either be off or on.
1195+ * 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.
1196+ * The overall state of the engine. Can either be off, on or active.
1197+
1198+The Service takes this configuration and exposes it to client
1199+applications. In addition, mainly for debugging purposes, the set of
1200+currently visible satellites (if any) is maintained and exposed to
1201+privileged client applications.
1202+
1203+## Privacy & Access Control
1204+
1205+Location information is highly privacy relevant. For this reason, the
1206+location service is deeply integrated with AppArmor and Ubuntu's
1207+overall trust infrastructure. Every incoming session request is
1208+validated and if in doubt, the user is asked to explicitly grant trust
1209+to the application requesting access to positioning
1210+information. Please see [@ref com::ubuntu::location::service::PermissionManager]
1211+for further details.
1212+
1213+In addition, the location service allows for selectively adjusting the
1214+accuracy and reporting setup of the location Engine to provide further
1215+fine-grained control over the exposed data to user. Within this setup,
1216+a user is able to entirely disable all positioning.
1217+
1218
1219=== added file 'doc/manual_testing.md'
1220--- doc/manual_testing.md 1970-01-01 00:00:00 +0000
1221+++ doc/manual_testing.md 2016-04-05 17:17:30 +0000
1222@@ -0,0 +1,174 @@
1223+# Manual Testplan
1224+
1225+[TOC]
1226+
1227+While the automatic test suite of the location service is
1228+comprehensive and covers large parts of the functionality of the
1229+service itself, we still provide an additional level of acceptance
1230+testing covering the entire location stack/experience as a part of
1231+this document.
1232+
1233+## Dependents/Clients
1234+
1235+ - qtubuntu-sensors
1236+ - Qt/QML applications:
1237+ - Browser
1238+ - osmTouch
1239+
1240+## Test Plan
1241+
1242+This test plan is not supposed to be complete; use it to guide your
1243+manual testing so you don't miss big functional areas that are part of
1244+the component; also this should be used as guideline to inspire the
1245+exploratory testing which should be adapted smartly based on the real
1246+content of a MP.
1247+
1248+Please note that if you're testing the GPS provider, the location
1249+service relies on GPS hardware to obtain a location fix. For that, it
1250+might be required that you execute the manual steps listed before
1251+close to a window or ideally outside, with good satellite visibility
1252+conditions.
1253+
1254+__Note: It can take up to 15 minutes for the GPS device to get a lock, due to lack of assisted GPS__
1255+
1256+ - Install latest image on phone
1257+ - Install freshly built MPs that are needed for landing
1258+
1259+Depending on the default configuration of location-service on the
1260+image, you may skip parts of this test plan. E.g. if GPS hardware is
1261+disabled, skip this part. You can see which providers are enabled by
1262+looking at the list of providers on the location-serviced command-line
1263+(`ps fauxw | grep location-service`, then look at the `--provider`
1264+flags).
1265+
1266+### Dummy provider
1267+
1268+This tests forces location-service to use only the dummy provider;
1269+this providers a baseline test for the app to trust-store to
1270+location-service path.
1271+
1272+ - phablet-shell into the phone:
1273+ - `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`
1274+ - As phablet, start the trust store again (it stops when location-service is stopped) with: `start ubuntu-location-service-trust-stored`
1275+ - Ensure that all AP tests for the webbrowser pass as expected
1276+ - Point the browser to maps.google.com (alternatively: here.com, maps.bing.fr).
1277+ - Request centering the map on current position and observe if it works correctly (should show the Eiffel tower)
1278+ - Install osmTouch from the app store
1279+ - Launch osmTouch and check if it centers on the Eiffel tower.
1280+ - Install a maps webapp such as HERE or Google Maps webapp from the app store
1281+ - Launch maps webapp and check if it centers on the Eiffel tower.
1282+
1283+### GPS Test Plan
1284+
1285+This applies only if GPS provider is enabled.
1286+
1287+ - (If applicable: Remember to add the silo you are testing)
1288+ - `sudo apt-get install ubuntu-location-service-tests`
1289+ - 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:
1290+ - `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`
1291+ - If you '''don't''' want to send off crowdsourced information:
1292+ - `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`
1293+
1294+ - The test will output a lot of diagnostic information to the
1295+ terminal and will take ~30 minutes. If satellite visibility is
1296+ limited, it can take even longer. The test will automatically
1297+ report success or failure.
1298+
1299+### Preliminary AGPS Test Plan
1300+
1301+**Does not apply to Krillin**
1302+
1303+Please note that the Krillin GPS chipset driver and its integration
1304+within Ubuntu does not support vanilla AGPS (i.e., SUPL) right
1305+now. For that, this test case is irrelevant for Krillin and is likely
1306+to fail.
1307+
1308+This applied only if GPS provider and some other provider (giving
1309+_A_ssistance) are enabled.
1310+
1311+ - Add the silo.
1312+ - `sudo apt-get install ubuntu-location-service-tests`
1313+ - Obtain a (rough) location estimate for your current location on Google maps.
1314+ - Make sure to replace INSERT_ESTIMATE_HERE with the respective
1315+ values obtained from Google maps.
1316+ - If you want to send off crowdsourced information, i.e., information
1317+ about visible wifis and visible radio cells for the obtained
1318+ location fixes to Mozilla's location service and our own instance:
1319+ - `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`
1320+ - If you '''don't''' want to send off crowdsourced information:
1321+ - `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`
1322+
1323+ - The test will output a lot of diagnostic information to the
1324+ terminal and will take ~10 minutes or less. The test will
1325+ automatically report success or failure.
1326+
1327+### Espoo / HERE provider
1328+
1329+This applies only if the Espoo / HERE remote provider is enabled. This
1330+provider should be enabled by default and may either work standalone
1331+as the only provider or as an assistance for the GPS hardware to lock.
1332+
1333+ - Add the silo; special exception for lxc-android-config: see https://wiki.ubuntu.com/Touch/Testing/lxc-android-config
1334+ - If noted, deploy an updated custom tarball:
1335+ - Download the tarball under /tmp ('''NOT''' under /)
1336+ - Unpack there: `cd /tmp; sudo tar xvf custom-vendor-here-*.tar.xz`
1337+ - Remove older bits: `sudo rm -rf /custom/vendor/here/`
1338+ - Update custom bits: `sudo mv /tmp/system/custom/vendor/here /custom/vendor`
1339+ - Reboot
1340+ - After boot, check you have these three processes running on top of location-service:
1341+ - slpgwd
1342+ - posclientd
1343+ - ubuntu-espoo-service
1344+ - Make sure SIM is unlocked and attached to the network (has some reliable signal) and that WiFi is turned on.
1345+ - Install OSMTouch app
1346+ - Run OSMTouch app, hit the position button every other second until you get a blue circle showing your current location;
1347+
1348+# Connectivity API
1349+
1350+For integration of network-based positioning providers, the location
1351+service offers a connectivity API that provides access to wifi and
1352+cell measurements as well as information on the current overall
1353+connectivity status of the device. Please execute the following
1354+commands on a newly flashed device with a writable image:
1355+
1356+ - `sudo apt-get update && sudo apt-get build-dep location-service && sudo apt-get install libubuntu-location-service-dev ubuntu-location-service-examples`
1357+ - `mkdir /tmp/build && cd /tmp/build && cmake /usr/share/ubuntu-location-service/examples/standalone/connectivity/ && make`
1358+ - `GLOG_logtostderr=1 ./connectivity`
1359+
1360+Verify that the output looks similar to:
1361+
1362+ phablet@ubuntu-phablet:/tmp/build$ ./connectivity
1363+ Is wifi enabled: true
1364+ Is wifi hw enabled: true
1365+ Is wwan enabled: false
1366+ Is wwan hw enabled: true
1367+ umts(mcc: 262, mnc: 2, lac: 5313, id: 131948771, asu: 7)
1368+ (bssid: BC:F2:AF:AF:19:A2, ssid: devolo-bcf2afaf19a2, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2462, strength: 72)
1369+ (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 24)
1370+ (bssid: 82:C7:A6:40:8C:4E, ssid: EasyBox-44D054, last seen: 1408955206, mode: Mode::infrastructure, frequency: 2417, strength: 17)
1371+ (bssid: 00:24:01:B8:32:8D, ssid: gra, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 12)
1372+ (bssid: C0:25:06:3C:28:22, ssid: FRITZ!Box 6360 Cable, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2412, strength: 17)
1373+ (bssid: 00:1C:4A:A5:B7:59, ssid: FRITZ!Box Fon WLAN 7170, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2437, strength: 10)
1374+ 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)
1375+ Last seen changed for wifi (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955257, mode: Mode::infrastructure, frequency: 2412, strength: 24)
1376+ 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)
1377+
1378+# Trust Store Integration
1379+
1380+Please note that we are assuming a freshly wiped system for testing
1381+here. If you cannot fulfill that pre-condition, please run `rm -rf
1382+/home/phablet/.local/share/UbuntuLocationService && sudo shutdown -r` prior to running the
1383+tests:
1384+
1385+## Unconfined
1386+
1387+ - Open the browser, go to maps.google.com
1388+ - Observe the in-browser dialog asking for granting access to location.
1389+
1390+## Confined Web-App
1391+
1392+ - Open the Nokia Here web app, observe the trust dialog appearing.
1393+
1394+## Confined Application
1395+
1396+ - Open osmtouch and observe the osmtouch surface sliding up, presenting you with a trust dialog.
1397
1398=== added file 'doc/tips_n_tricks.md'
1399--- doc/tips_n_tricks.md 1970-01-01 00:00:00 +0000
1400+++ doc/tips_n_tricks.md 2016-04-05 17:17:30 +0000
1401@@ -0,0 +1,21 @@
1402+# Tips'n'Tricks
1403+
1404+## Mark HERE license as accepted from cmdline
1405+
1406+ 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>'
1407+
1408+## Force startup after ofono and NM are started
1409+
1410+This is a *workaround* to get connectivity API to collect; mount your
1411+system read-write and edit
1412+/etc/init/ubuntu-location-provider-here-slpgwd.conf:
1413+
1414+ sudo mount -o remount,rw /
1415+ sudo vi /etc/init/ubuntu-location-provider-here-slpgwd.conf
1416+
1417+change: `start on started dbus and (started ofono or started network-manager)`
1418+to: `start on started dbus and started ofono and started network-manager`
1419+
1420+ sudo mount -o remount,ro /
1421+ sync
1422+ sudo reboot
1423
1424=== modified file 'examples/service/service.cpp'
1425--- examples/service/service.cpp 2014-11-14 11:26:45 +0000
1426+++ examples/service/service.cpp 2016-04-05 17:17:30 +0000
1427@@ -99,7 +99,10 @@
1428 auto selected_providers = options.value_for_key<std::vector<std::string>>("provider");
1429
1430 std::map<std::string, cul::ProviderFactory::Configuration> config_lut;
1431- std::set<cul::Provider::Ptr> instantiated_providers;
1432+
1433+ culs::DefaultConfiguration config;
1434+ auto settings = std::make_shared<cul::BoostPtreeSettings>(options.value_for_key<std::string>("config-file"));
1435+ auto engine = config.the_engine(std::set<cul::Provider::Ptr>{}, config.the_provider_selection_policy(), settings);
1436
1437 for (const std::string& provider : selected_providers)
1438 {
1439@@ -129,15 +132,15 @@
1440
1441 try
1442 {
1443- auto p = cul::ProviderFactory::instance().create_provider_for_name_with_config(
1444- provider,
1445- config_lut[provider]);
1446-
1447- if (p)
1448- instantiated_providers.insert(p);
1449- else
1450- throw std::runtime_error("Problem instantiating provider");
1451-
1452+ auto result = std::async(std::launch::async, [provider, config_lut, engine] {
1453+ return cul::ProviderFactory::instance().create_provider_for_name_with_config(
1454+ provider,
1455+ config_lut.at(provider),
1456+ [engine](cul::Provider::Ptr provider)
1457+ {
1458+ engine->add_provider(provider);
1459+ });
1460+ });
1461 } catch(const std::runtime_error& e)
1462 {
1463 std::cerr << "Exception instantiating provider: " << e.what() << " ... Aborting now." << std::endl;
1464@@ -163,15 +166,11 @@
1465 };
1466 outgoing->install_executor(dbus::asio::make_executor(outgoing));
1467
1468- auto settings = std::make_shared<cul::BoostPtreeSettings>(options.value_for_key<std::string>("config-file"));
1469-
1470- culs::DefaultConfiguration config;
1471-
1472 culs::Implementation::Configuration configuration
1473 {
1474 incoming,
1475 outgoing,
1476- config.the_engine(instantiated_providers, config.the_provider_selection_policy(), settings),
1477+ engine,
1478 config.the_permission_manager(incoming),
1479 culs::Harvester::Configuration
1480 {
1481
1482=== modified file 'include/location_service/com/ubuntu/location/provider_factory.h'
1483--- include/location_service/com/ubuntu/location/provider_factory.h 2014-10-27 21:58:16 +0000
1484+++ include/location_service/com/ubuntu/location/provider_factory.h 2016-04-05 17:17:30 +0000
1485@@ -54,6 +54,9 @@
1486 // --provider=remote::Provider@gps --remote::Provider@gps::name="com.ubuntu.android.gps.Provider" --remote::Provider@gps::path="/com/ubuntu/android/gps/Provider"
1487 Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config);
1488
1489+ // Async version of above.
1490+ void create_provider_for_name_with_config(const std::string& name, const Configuration& config, const std::function<void(Provider::Ptr)>& cb);
1491+
1492 void enumerate(const std::function<void(const std::string&, const Factory&)>& enumerator);
1493
1494 private:
1495
1496=== modified file 'po/ubuntu-location-service.pot'
1497--- po/ubuntu-location-service.pot 2014-09-19 09:06:30 +0000
1498+++ po/ubuntu-location-service.pot 2016-04-05 17:17:30 +0000
1499@@ -1,13 +1,14 @@
1500-# Copyright (C) 2014 Canonical Ltd.
1501-# This file is distributed under the same license as the ubuntu-location-service package.
1502-# Thomas Voß <thomas.voss@canonical.com>, 2014.
1503+# SOME DESCRIPTIVE TITLE.
1504+# Copyright (C) YEAR Canonical Ltd.
1505+# This file is distributed under the same license as the PACKAGE package.
1506+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
1507 #
1508 #, fuzzy
1509 msgid ""
1510 msgstr ""
1511 "Project-Id-Version: ubuntu-location-service\n"
1512 "Report-Msgid-Bugs-To: \n"
1513-"POT-Creation-Date: 2014-09-19 01:04+0200\n"
1514+"POT-Creation-Date: 2015-11-27 14:07+0100\n"
1515 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1516 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1517 "Language-Team: LANGUAGE <LL@li.org>\n"
1518@@ -16,11 +17,6 @@
1519 "Content-Type: text/plain; charset=CHARSET\n"
1520 "Content-Transfer-Encoding: 8bit\n"
1521
1522-#: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:170
1523-msgid "An unconfined application wants to access your current location."
1524-msgstr ""
1525-
1526-#: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:173
1527-#, boost-format
1528-msgid "%1% wants to access your current location."
1529+#: /home/tvoss/ubuntu/scratch/fix-prompt-string/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:149
1530+msgid "wants to access your current location."
1531 msgstr ""
1532
1533=== modified file 'src/location_service/com/ubuntu/location/CMakeLists.txt'
1534--- src/location_service/com/ubuntu/location/CMakeLists.txt 2015-04-23 14:48:44 +0000
1535+++ src/location_service/com/ubuntu/location/CMakeLists.txt 2016-04-05 17:17:30 +0000
1536@@ -38,6 +38,7 @@
1537 service/harvester.cpp
1538 service/demultiplexing_reporter.h
1539 service/demultiplexing_reporter.cpp
1540+ service/runtime.cpp
1541 service/runtime_tests.h
1542 service/runtime_tests.cpp
1543 service/trust_store_permission_manager.cpp
1544
1545=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp'
1546--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-05-28 10:57:24 +0000
1547+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2016-04-05 17:17:30 +0000
1548@@ -123,7 +123,14 @@
1549 const org::freedesktop::NetworkManager::Device& device,
1550 const org::freedesktop::NetworkManager::AccessPoint& ap)
1551 : device_(device),
1552- access_point_(ap)
1553+ access_point_(ap),
1554+ connections
1555+ {
1556+ access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
1557+ {
1558+ on_access_point_properties_changed(dict);
1559+ })
1560+ }
1561 {
1562 last_seen_ = translate_time_stamp(access_point_.last_seen->get());
1563
1564@@ -138,12 +145,11 @@
1565 {
1566 static_cast<int>(access_point_.strength->get())
1567 };
1568+}
1569
1570- // Wire up all the connections
1571- access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
1572- {
1573- on_access_point_properties_changed(dict);
1574- });
1575+detail::CachedWirelessNetwork::~CachedWirelessNetwork()
1576+{
1577+ access_point_.properties_changed->disconnect(connections.ap_properties_changed);
1578 }
1579
1580 void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)
1581
1582=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h'
1583--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2014-08-14 20:25:22 +0000
1584+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2016-04-05 17:17:30 +0000
1585@@ -41,6 +41,8 @@
1586 const org::freedesktop::NetworkManager::Device& device,
1587 const org::freedesktop::NetworkManager::AccessPoint& ap);
1588
1589+ ~CachedWirelessNetwork();
1590+
1591 // Timestamp when the network became visible.
1592 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;
1593
1594@@ -67,6 +69,16 @@
1595 // The actual access point stub.
1596 org::freedesktop::NetworkManager::AccessPoint access_point_;
1597
1598+ // Encapsulates all event connections that have to be cut on destruction.
1599+ struct
1600+ {
1601+ core::dbus::Signal
1602+ <
1603+ org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged,
1604+ org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged::ArgumentType
1605+ >::SubscriptionToken ap_properties_changed;
1606+ } connections;
1607+
1608 core::Property<std::chrono::system_clock::time_point> last_seen_;
1609 core::Property<std::string> bssid_;
1610 core::Property<std::string> ssid_;
1611
1612=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp'
1613--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-05-27 18:40:37 +0000
1614+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2016-04-05 17:17:30 +0000
1615@@ -595,7 +595,7 @@
1616
1617 xdg::NetworkManager::AccessPoint ap
1618 {
1619- network_manager->service->add_object_for_path(ap_path)
1620+ network_manager->service->object_for_path(ap_path)
1621 };
1622
1623 auto wifi = std::make_shared<detail::CachedWirelessNetwork>(itd->second, ap);
1624
1625=== modified file 'src/location_service/com/ubuntu/location/engine.cpp'
1626--- src/location_service/com/ubuntu/location/engine.cpp 2015-04-23 14:48:44 +0000
1627+++ src/location_service/com/ubuntu/location/engine.cpp 2016-04-05 17:17:30 +0000
1628@@ -97,10 +97,7 @@
1629 Configuration::Keys::engine_state,
1630 Configuration::Defaults::engine_state);
1631
1632- configuration.satellite_based_positioning_state =
1633- settings->get_enum_for_key<SatelliteBasedPositioningState>(
1634- Configuration::Keys::satellite_based_positioning_state,
1635- Configuration::Defaults::satellite_based_positioning_state);
1636+ configuration.satellite_based_positioning_state = Configuration::Defaults::satellite_based_positioning_state;
1637
1638 configuration.wifi_and_cell_id_reporting_state =
1639 settings->get_enum_for_key<WifiAndCellIdReportingState>(
1640@@ -110,12 +107,7 @@
1641 configuration.engine_state.changed().connect([this](const Engine::Status& status)
1642 {
1643 Engine::settings->set_enum_for_key<Engine::Status>(Configuration::Keys::engine_state, status);
1644- });
1645-
1646- configuration.satellite_based_positioning_state.changed().connect([this](SatelliteBasedPositioningState state)
1647- {
1648- Engine::settings->set_enum_for_key<SatelliteBasedPositioningState>(Configuration::Keys::satellite_based_positioning_state, state);
1649- });
1650+ });
1651
1652 configuration.wifi_and_cell_id_reporting_state.changed().connect([this](WifiAndCellIdReportingState state)
1653 {
1654@@ -129,10 +121,6 @@
1655 Configuration::Keys::engine_state,
1656 configuration.engine_state);
1657
1658- settings->set_enum_for_key<SatelliteBasedPositioningState>(
1659- Configuration::Keys::satellite_based_positioning_state,
1660- configuration.satellite_based_positioning_state);
1661-
1662 settings->set_enum_for_key<WifiAndCellIdReportingState>(
1663 Configuration::Keys::wifi_and_cell_id_reporting_state,
1664 configuration.wifi_and_cell_id_reporting_state);
1665@@ -169,19 +157,28 @@
1666
1667 // We wire up changes in the engine's configuration to the respective slots
1668 // of the provider.
1669- auto cp = updates.reference_location.changed().connect([provider](const cul::Update<cul::Position>& pos)
1670- {
1671- provider->on_reference_location_updated(pos);
1672- });
1673-
1674- auto cv = updates.reference_velocity.changed().connect([provider](const cul::Update<cul::Velocity>& velocity)
1675- {
1676- provider->on_reference_velocity_updated(velocity);
1677- });
1678-
1679- auto ch = updates.reference_heading.changed().connect([provider](const cul::Update<cul::Heading>& heading)
1680- {
1681- provider->on_reference_heading_updated(heading);
1682+ auto cp = updates.last_known_location.changed().connect([provider](const cul::Optional<cul::Update<cul::Position>>& pos)
1683+ {
1684+ if (pos)
1685+ {
1686+ provider->on_reference_location_updated(pos.get());
1687+ }
1688+ });
1689+
1690+ auto cv = updates.last_known_velocity.changed().connect([provider](const cul::Optional<cul::Update<cul::Velocity>>& velocity)
1691+ {
1692+ if (velocity)
1693+ {
1694+ provider->on_reference_velocity_updated(velocity.get());
1695+ }
1696+ });
1697+
1698+ auto ch = updates.last_known_heading.changed().connect([provider](const cul::Optional<cul::Update<cul::Heading>>& heading)
1699+ {
1700+ if (heading)
1701+ {
1702+ provider->on_reference_heading_updated(heading.get());
1703+ }
1704 });
1705
1706 auto cr = configuration.wifi_and_cell_id_reporting_state.changed().connect([provider](cul::WifiAndCellIdReportingState state)
1707@@ -207,7 +204,7 @@
1708 // We should come up with a better heuristic here.
1709 auto cpr = provider->updates().position.connect([this](const cul::Update<cul::Position>& src)
1710 {
1711- updates.reference_location = update_policy->verify_update(src);
1712+ updates.last_known_location = update_policy->verify_update(src);
1713 });
1714
1715 std::lock_guard<std::mutex> lg(guard);
1716
1717=== modified file 'src/location_service/com/ubuntu/location/engine.h'
1718--- src/location_service/com/ubuntu/location/engine.h 2015-04-23 14:48:44 +0000
1719+++ src/location_service/com/ubuntu/location/engine.h 2016-04-05 17:17:30 +0000
1720@@ -127,11 +127,11 @@
1721 struct Updates
1722 {
1723 /** The current best known reference location */
1724- core::Property<Update<Position>> reference_location{};
1725+ core::Property<Optional<Update<Position>>> last_known_location{};
1726 /** The current best known velocity estimate. */
1727- core::Property<Update<Velocity>> reference_velocity{};
1728+ core::Property<Optional<Update<Velocity>>> last_known_velocity{};
1729 /** The current best known heading estimate. */
1730- core::Property<Update<Heading>> reference_heading{};
1731+ core::Property<Optional<Update<Heading>>> last_known_heading{};
1732 /** The current set of visible SpaceVehicles. */
1733 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>> visible_space_vehicles{};
1734 };
1735
1736=== modified file 'src/location_service/com/ubuntu/location/provider_factory.cpp'
1737--- src/location_service/com/ubuntu/location/provider_factory.cpp 2014-10-27 21:58:16 +0000
1738+++ src/location_service/com/ubuntu/location/provider_factory.cpp 2016-04-05 17:17:30 +0000
1739@@ -52,6 +52,20 @@
1740 return cul::Provider::Ptr{factory_store.at(undecorated_name)(config)};
1741 }
1742
1743+void cul::ProviderFactory::create_provider_for_name_with_config(
1744+ const std::string& name,
1745+ const cul::ProviderFactory::Configuration& config,
1746+ const std::function<void(Provider::Ptr)>& cb)
1747+{
1748+ auto undecorated_name = name.substr(0, name.find("@"));
1749+
1750+ std::lock_guard<std::mutex> lg(guard);
1751+ if (factory_store.count(undecorated_name) == 0)
1752+ return;
1753+
1754+ cb(cul::Provider::Ptr{factory_store.at(undecorated_name)(config)});
1755+}
1756+
1757 void cul::ProviderFactory::enumerate(
1758 const std::function<void(const std::string&, const cul::ProviderFactory::Factory&)>& enumerator)
1759 {
1760
1761=== modified file 'src/location_service/com/ubuntu/location/providers/config.cpp'
1762--- src/location_service/com/ubuntu/location/providers/config.cpp 2014-09-15 08:58:50 +0000
1763+++ src/location_service/com/ubuntu/location/providers/config.cpp 2016-04-05 17:17:30 +0000
1764@@ -19,6 +19,7 @@
1765 #include <com/ubuntu/location/provider_factory.h>
1766
1767 #include "dummy/provider.h"
1768+#include "dummy/delayed_provider.h"
1769
1770 #include <map>
1771
1772@@ -41,6 +42,12 @@
1773 com::ubuntu::location::providers::dummy::Provider::create_instance
1774 };
1775
1776+static FactoryInjector dummy_delayed_injector
1777+{
1778+ "dummy::DelayedProvider",
1779+ com::ubuntu::location::providers::dummy::DelayedProvider::create_instance
1780+};
1781+
1782 #include <com/ubuntu/location/providers/remote/provider.h>
1783 static FactoryInjector remote_injector
1784 {
1785
1786=== modified file 'src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt'
1787--- src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt 2014-02-07 17:16:49 +0000
1788+++ src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt 2016-04-05 17:17:30 +0000
1789@@ -2,7 +2,9 @@
1790 dummy
1791
1792 provider.h
1793- provider.cpp)
1794+ provider.cpp
1795+ delayed_provider.h
1796+ delayed_provider.cpp)
1797
1798 set(
1799 ENABLED_PROVIDER_TARGETS
1800
1801=== added file 'src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp'
1802--- src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp 1970-01-01 00:00:00 +0000
1803+++ src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp 2016-04-05 17:17:30 +0000
1804@@ -0,0 +1,42 @@
1805+/*
1806+ * Copyright © 2015 Canonical Ltd.
1807+ *
1808+ * This program is free software: you can redistribute it and/or modify it
1809+ * under the terms of the GNU Lesser General Public License version 3,
1810+ * as published by the Free Software Foundation.
1811+ *
1812+ * This program is distributed in the hope that it will be useful,
1813+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1814+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1815+ * GNU Lesser General Public License for more details.
1816+ *
1817+ * You should have received a copy of the GNU Lesser General Public License
1818+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1819+ *
1820+ * Authored by: Scott Sweeny <scott.sweeny@canonical.com>
1821+ */
1822+
1823+#include <com/ubuntu/location/logging.h>
1824+
1825+#include <chrono>
1826+#include <thread>
1827+
1828+#include "delayed_provider.h"
1829+
1830+namespace location = com::ubuntu::location;
1831+namespace dummy = com::ubuntu::location::providers::dummy;
1832+
1833+std::string dummy::DelayedProvider::class_name()
1834+{
1835+ return "dummy::DelayedProvider";
1836+}
1837+
1838+location::Provider::Ptr dummy::DelayedProvider::create_instance(const ProviderFactory::Configuration& config)
1839+{
1840+ int delay = config.get(dummy::DelayConfiguration::Keys::delay, 0);
1841+ VLOG(1) << __PRETTY_FUNCTION__ << ": delay for " << delay << "ms";
1842+
1843+ std::this_thread::sleep_for(std::chrono::milliseconds{delay});
1844+
1845+ return dummy::Provider::create_instance(config);
1846+}
1847
1848=== added file 'src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h'
1849--- src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h 1970-01-01 00:00:00 +0000
1850+++ src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h 2016-04-05 17:17:30 +0000
1851@@ -0,0 +1,62 @@
1852+/*
1853+ * Copyright © 2015 Canonical Ltd.
1854+ *
1855+ * This program is free software: you can redistribute it and/or modify it
1856+ * under the terms of the GNU Lesser General Public License version 3,
1857+ * as published by the Free Software Foundation.
1858+ *
1859+ * This program is distributed in the hope that it will be useful,
1860+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1861+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1862+ * GNU Lesser General Public License for more details.
1863+ *
1864+ * You should have received a copy of the GNU Lesser General Public License
1865+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1866+ *
1867+ * Authored by: Scott Sweeny <scott.sweeny@canonical.com>
1868+ */
1869+
1870+#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_DELAYED_PROVIDER_H_
1871+#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_DELAYED_PROVIDER_H_
1872+
1873+#include "provider.h"
1874+
1875+namespace com
1876+{
1877+namespace ubuntu
1878+{
1879+namespace location
1880+{
1881+namespace providers
1882+{
1883+namespace dummy
1884+{
1885+ struct DelayConfiguration
1886+ {
1887+ struct Keys
1888+ {
1889+ static constexpr const char* delay
1890+ {
1891+ "DelayInMs"
1892+ };
1893+ };
1894+ };
1895+
1896+class DelayedProvider : public Provider
1897+{
1898+ public:
1899+ // For integration with the Provider factory
1900+ static std::string class_name();
1901+ // Waits for "DelayInMs" from the provided property bundle then
1902+ // instantiates a new provider instance, populating the configuration object
1903+ // from the provided property bundle.
1904+ static DelayedProvider::Ptr create_instance(const ProviderFactory::Configuration&);
1905+ // Creates a new provider instance from the given configuration.
1906+ DelayedProvider(const Configuration config = Configuration{});
1907+};
1908+}
1909+}
1910+}
1911+}
1912+}
1913+#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_DELAYED_PROVIDER_H_
1914
1915=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp'
1916--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2014-10-27 21:58:16 +0000
1917+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2016-04-05 17:17:30 +0000
1918@@ -66,8 +66,6 @@
1919 if (config.count("XTRA_SERVER_3") > 0)
1920 result.xtra_hosts.push_back(config.get<std::string>("XTRA_SERVER_3"));
1921
1922- result.timeout = std::chrono::milliseconds{1500};
1923-
1924 return result;
1925 }
1926
1927@@ -333,14 +331,14 @@
1928 } else
1929 {
1930 auto now = location::Clock::now().time_since_epoch();
1931- auto thiz = static_cast<android::HardwareAbstractionLayer*>(context);
1932+ auto ms_since_epoch = std::chrono::duration_cast<std::chrono::milliseconds>(now);
1933
1934 static const int zero_uncertainty = 0;
1935
1936 u_hardware_gps_inject_time(
1937 thiz->impl.gps_handle,
1938- now.count(),
1939- now.count(),
1940+ ms_since_epoch.count(),
1941+ ms_since_epoch.count(),
1942 zero_uncertainty);
1943 }
1944 }
1945
1946=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h'
1947--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2015-04-22 13:30:04 +0000
1948+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2016-04-05 17:17:30 +0000
1949@@ -49,7 +49,7 @@
1950 /** @brief Timeout on gps xtra download operations. */
1951 std::chrono::milliseconds timeout
1952 {
1953- 5000
1954+ 30000
1955 };
1956
1957 /** Set of hosts serving GPS xtra data. */
1958
1959=== modified file 'src/location_service/com/ubuntu/location/providers/remote/provider.cpp'
1960--- src/location_service/com/ubuntu/location/providers/remote/provider.cpp 2015-04-14 18:54:00 +0000
1961+++ src/location_service/com/ubuntu/location/providers/remote/provider.cpp 2016-04-05 17:17:30 +0000
1962@@ -23,6 +23,7 @@
1963 #include <com/ubuntu/location/logging.h>
1964
1965 #include <core/dbus/object.h>
1966+#include <core/dbus/service_watcher.h>
1967 #include <core/dbus/signal.h>
1968 #include <core/dbus/asio/executor.h>
1969
1970@@ -191,6 +192,28 @@
1971 auto service = dbus::Service::use_service(bus, name);
1972 auto object = service->object_for_path(path);
1973
1974+ // Check if the service has come up
1975+ if (!bus->has_owner_for_name(name)) {
1976+ // If it hasn't wait for it to come up
1977+ bool valid = false;
1978+ std::mutex guard;
1979+ std::condition_variable cv;
1980+ dbus::DBus daemon(bus);
1981+ dbus::ServiceWatcher::Ptr service_watcher(
1982+ daemon.make_service_watcher(name, dbus::DBus::WatchMode::registration));
1983+
1984+ service_watcher->service_registered().connect([&valid, &guard, &cv]()
1985+ {
1986+ std::unique_lock<std::mutex> ul(guard);
1987+ valid = true;
1988+ cv.notify_all();
1989+ });
1990+
1991+ std::unique_lock<std::mutex> ul(guard);
1992+ if (not cv.wait_for(ul, std::chrono::seconds{30}, [&valid]() { return valid; }))
1993+ throw std::runtime_error("Remote service failed to start");
1994+ }
1995+
1996 return create_instance_with_config(remote::stub::Configuration{object});
1997 }
1998
1999
2000=== modified file 'src/location_service/com/ubuntu/location/service/daemon.cpp'
2001--- src/location_service/com/ubuntu/location/service/daemon.cpp 2015-04-16 10:03:29 +0000
2002+++ src/location_service/com/ubuntu/location/service/daemon.cpp 2016-04-05 17:17:30 +0000
2003@@ -20,6 +20,9 @@
2004 #include <com/ubuntu/location/boost_ptree_settings.h>
2005 #include <com/ubuntu/location/provider_factory.h>
2006
2007+#include <com/ubuntu/location/logging.h>
2008+#include <com/ubuntu/location/connectivity/dummy_connectivity_manager.h>
2009+
2010 #include <com/ubuntu/location/service/default_configuration.h>
2011 #include <com/ubuntu/location/service/demultiplexing_reporter.h>
2012 #include <com/ubuntu/location/service/ichnaea_reporter.h>
2013@@ -30,6 +33,7 @@
2014
2015 #include "program_options.h"
2016 #include "daemon.h"
2017+#include "runtime.h"
2018
2019 #include <core/dbus/announcer.h>
2020 #include <core/dbus/resolver.h>
2021@@ -37,6 +41,8 @@
2022
2023 #include <core/posix/signal.h>
2024
2025+#include <boost/asio.hpp>
2026+
2027 #include <system_error>
2028 #include <thread>
2029
2030@@ -175,116 +181,55 @@
2031 trap->stop();
2032 });
2033
2034- const location::Configuration empty_provider_configuration;
2035-
2036- std::set<location::Provider::Ptr> instantiated_providers;
2037-
2038+ auto runtime = location::service::Runtime::create(4);
2039+
2040+ location::service::DefaultConfiguration dc;
2041+ auto engine = dc.the_engine(std::set<location::Provider::Ptr>{}, dc.the_provider_selection_policy(), config.settings);
2042 for (const std::string& provider : config.providers)
2043 {
2044 std::cout << "Instantiating and configuring: " << provider << std::endl;
2045
2046 try
2047 {
2048- auto p = location::ProviderFactory::instance().create_provider_for_name_with_config(
2049- provider,
2050- config.provider_options.count(provider) > 0 ?
2051- config.provider_options.at(provider) : empty_provider_configuration);
2052-
2053- if (p)
2054- instantiated_providers.insert(p);
2055- else
2056- throw std::runtime_error("Problem instantiating provider");
2057-
2058+ auto result = std::async(std::launch::async, [provider, config, engine] {
2059+ return location::ProviderFactory::instance().create_provider_for_name_with_config(
2060+ provider,
2061+ config.provider_options.count(provider) > 0 ?
2062+ config.provider_options.at(provider) : location::Configuration {},
2063+ [engine](Provider::Ptr provider)
2064+ {
2065+ engine->add_provider(provider);
2066+ }
2067+ );
2068+ });
2069 } catch(const std::runtime_error& e)
2070 {
2071 std::cerr << "Issue instantiating provider: " << e.what() << std::endl;
2072 }
2073 }
2074
2075- config.incoming->install_executor(dbus::asio::make_executor(config.incoming));
2076- config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing));
2077+ config.incoming->install_executor(dbus::asio::make_executor(config.incoming, runtime->service()));
2078+ config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing, runtime->service()));
2079
2080- location::service::DefaultConfiguration dc;
2081+ runtime->start();
2082
2083 location::service::Implementation::Configuration configuration
2084 {
2085 config.incoming,
2086 config.outgoing,
2087- dc.the_engine(instantiated_providers, dc.the_provider_selection_policy(), config.settings),
2088+ engine,
2089 dc.the_permission_manager(config.outgoing),
2090 location::service::Harvester::Configuration
2091 {
2092- location::connectivity::platform_default_manager(),
2093- // We submit location/wifi/cell measurements to both
2094- // Mozilla's location service and to Ubuntu's own instance.
2095- std::make_shared<service::DemultiplexingReporter>(
2096- std::initializer_list<service::Harvester::Reporter::Ptr>
2097- {
2098- std::make_shared<service::ichnaea::Reporter>(
2099- service::ichnaea::Reporter::Configuration
2100- {
2101- "https://location.services.mozilla.com",
2102- "UbuntuLocationService",
2103- "UbuntuLocationService"
2104- }
2105- ),
2106- std::make_shared<service::ichnaea::Reporter>(
2107- service::ichnaea::Reporter::Configuration
2108- {
2109- "https://162.213.35.107",
2110- "UbuntuLocationService",
2111- "UbuntuLocationService"
2112- }
2113- )
2114- })
2115+ std::make_shared<dummy::ConnectivityManager>(),
2116+ std::make_shared<NullReporter>()
2117 }
2118 };
2119
2120 auto location_service = std::make_shared<location::service::Implementation>(configuration);
2121- // We need to ensure that any exception raised by the executor does not crash the app
2122- // and also gets logged.
2123- auto execute = [] (std::shared_ptr<core::dbus::Bus> bus) {
2124- while(true)
2125- {
2126- try
2127- {
2128- VLOG(10) << "Starting a bus executor";
2129- bus->run();
2130- break; // run() exited normally
2131- }
2132- catch (const std::exception& e)
2133- {
2134- LOG(WARNING) << e.what();
2135- }
2136- catch (...)
2137- {
2138- LOG(WARNING) << "Unexpected exception was raised by the bus executor";
2139- }
2140- }
2141- };
2142-
2143- std::thread t1{execute, config.incoming};
2144- std::thread t2{execute, config.incoming};
2145- std::thread t3{execute, config.incoming};
2146- std::thread t4{execute, config.outgoing};
2147
2148 trap->run();
2149
2150- config.incoming->stop();
2151- config.outgoing->stop();
2152-
2153- if (t1.joinable())
2154- t1.join();
2155-
2156- if (t2.joinable())
2157- t2.join();
2158-
2159- if (t3.joinable())
2160- t3.join();
2161-
2162- if (t4.joinable())
2163- t4.join();
2164-
2165 return EXIT_SUCCESS;
2166 }
2167
2168
2169=== modified file 'src/location_service/com/ubuntu/location/service/implementation.cpp'
2170--- src/location_service/com/ubuntu/location/service/implementation.cpp 2014-08-13 13:08:22 +0000
2171+++ src/location_service/com/ubuntu/location/service/implementation.cpp 2016-04-05 17:17:30 +0000
2172@@ -113,10 +113,13 @@
2173 {
2174 visible_space_vehicles() = svs;
2175 }),
2176- configuration.engine->updates.reference_location.changed().connect(
2177- [this](const cul::Update<cul::Position>& update)
2178+ configuration.engine->updates.last_known_location.changed().connect(
2179+ [this](const cul::Optional<cul::Update<cul::Position>>& update)
2180 {
2181- harvester.report_position_update(update);
2182+ if (update)
2183+ {
2184+ harvester.report_position_update(update.get());
2185+ }
2186 })
2187 }
2188 {
2189@@ -149,5 +152,23 @@
2190 new ProxyProvider{provider_selection}
2191 };
2192
2193- return session::Interface::Ptr{new culs::session::Implementation(proxy_provider)};
2194+ session::Interface::Ptr session_iface{new session::Implementation(proxy_provider)};
2195+ std::weak_ptr<session::Interface> session_weak{session_iface};
2196+ session_iface->updates().position_status.changed().connect([this, session_weak](const session::Interface::Updates::Status& status)
2197+ {
2198+ cul::Optional<cul::Update<cul::Position>> last_known_position = configuration.engine->updates.last_known_location.get();
2199+ bool has_last_known_position = last_known_position ? true : false;
2200+ bool is_session_enabled = status == culs::session::Interface::Updates::Status::enabled;
2201+ bool is_session_on_or_active = configuration.engine->configuration.engine_state != Engine::Status::off;
2202+
2203+ if (has_last_known_position && is_session_enabled && is_session_on_or_active)
2204+ {
2205+ // Immediately send the last known position to the client
2206+ if (auto session_iface = session_weak.lock())
2207+ {
2208+ session_iface->updates().position = last_known_position.get();
2209+ }
2210+ }
2211+ });
2212+ return session_iface;
2213 }
2214
2215=== modified file 'src/location_service/com/ubuntu/location/service/provider_daemon.cpp'
2216--- src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2014-10-27 21:58:16 +0000
2217+++ src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2016-04-05 17:17:30 +0000
2218@@ -25,6 +25,7 @@
2219
2220 #include <com/ubuntu/location/service/configuration.h>
2221 #include <com/ubuntu/location/service/program_options.h>
2222+#include <com/ubuntu/location/service/runtime.h>
2223
2224 #include <core/dbus/asio/executor.h>
2225
2226@@ -65,7 +66,6 @@
2227 location::service::ProviderDaemon::Configuration result;
2228
2229 result.connection = factory(mutable_daemon_options().bus());
2230- result.connection->install_executor(core::dbus::asio::make_executor(result.connection));
2231
2232 auto service = core::dbus::Service::add_service(
2233 result.connection,
2234@@ -108,7 +108,15 @@
2235 return result;
2236 }
2237
2238-int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& configuration)
2239+namespace
2240+{
2241+std::shared_ptr<location::service::Runtime> runtime()
2242+{
2243+ static const auto inst = location::service::Runtime::create(2);
2244+ return inst;
2245+}
2246+}
2247+int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& config)
2248 {
2249 auto trap = core::posix::trap_signals_for_all_subsequent_threads(
2250 {
2251@@ -121,27 +129,20 @@
2252 trap->stop();
2253 });
2254
2255- std::thread worker
2256- {
2257- [configuration]()
2258- {
2259- configuration.connection->run();
2260- }
2261- };
2262+ config.connection->install_executor(core::dbus::asio::make_executor(config.connection, runtime()->service()));
2263
2264 auto skeleton = location::providers::remote::skeleton::create_with_configuration(location::providers::remote::skeleton::Configuration
2265 {
2266- configuration.object,
2267- configuration.connection,
2268- configuration.provider
2269+ config.object,
2270+ config.connection,
2271+ config.provider
2272 });
2273
2274+ runtime()->start();
2275+
2276 trap->run();
2277
2278- configuration.connection->stop();
2279-
2280- if (worker.joinable())
2281- worker.join();
2282+ config.connection->stop();
2283
2284 return EXIT_SUCCESS;
2285 }
2286
2287=== added file 'src/location_service/com/ubuntu/location/service/runtime.cpp'
2288--- src/location_service/com/ubuntu/location/service/runtime.cpp 1970-01-01 00:00:00 +0000
2289+++ src/location_service/com/ubuntu/location/service/runtime.cpp 2016-04-05 17:17:30 +0000
2290@@ -0,0 +1,109 @@
2291+/*
2292+ * Copyright © 2015 Canonical Ltd.
2293+ *
2294+ * This program is free software: you can redistribute it and/or modify it
2295+ * under the terms of the GNU Lesser General Public License version 3,
2296+ * as published by the Free Software Foundation.
2297+ *
2298+ * This program is distributed in the hope that it will be useful,
2299+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2300+ * MERCHANTABILITY or FITNESS FOR A PARTIlocationAR PURPOSE. See the
2301+ * GNU Lesser General Public License for more details.
2302+ *
2303+ * You should have received a copy of the GNU Lesser General Public License
2304+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2305+ *
2306+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
2307+ */
2308+#include <com/ubuntu/location/service/runtime.h>
2309+
2310+#include <com/ubuntu/location/logging.h>
2311+
2312+namespace culs = com::ubuntu::location::service;
2313+
2314+namespace
2315+{
2316+// exception_safe_run runs service, catching all exceptions and
2317+// restarting operation until an explicit shutdown has been requested.
2318+//
2319+// TODO(tvoss): Catching all exceptions is risky as they might signal unrecoverable
2320+// errors. We should enable calling code to decide whether an exception should be considered
2321+// fatal or not.
2322+void exception_safe_run(boost::asio::io_service& service)
2323+{
2324+ while (true)
2325+ {
2326+ try
2327+ {
2328+ service.run();
2329+ // a clean return from run only happens in case of
2330+ // stop() being called (we are keeping the service alive with
2331+ // a service::work instance).
2332+ break;
2333+ }
2334+ catch (const std::exception& e)
2335+ {
2336+ LOG(WARNING) << e.what();
2337+ }
2338+ catch (...)
2339+ {
2340+ LOG(WARNING) << "Unknown exception caught while executing boost::asio::io_service";
2341+ }
2342+ }
2343+}
2344+}
2345+
2346+std::shared_ptr<culs::Runtime> culs::Runtime::create(std::uint32_t pool_size)
2347+{
2348+ return std::shared_ptr<culs::Runtime>(new culs::Runtime(pool_size));
2349+}
2350+
2351+culs::Runtime::Runtime(std::uint32_t pool_size)
2352+ : pool_size_{pool_size},
2353+ service_{pool_size_},
2354+ strand_{service_},
2355+ keep_alive_{service_}
2356+{
2357+}
2358+
2359+culs::Runtime::~Runtime()
2360+{
2361+ try
2362+ {
2363+ stop();
2364+ } catch(...)
2365+ {
2366+ // Dropping all exceptions to satisfy the nothrow guarantee.
2367+ }
2368+}
2369+
2370+void culs::Runtime::start()
2371+{
2372+ for (unsigned int i = 0; i < pool_size_; i++)
2373+ workers_.push_back(std::thread{exception_safe_run, std::ref(service_)});
2374+}
2375+
2376+void culs::Runtime::stop()
2377+{
2378+ service_.stop();
2379+
2380+ for (auto& worker : workers_)
2381+ if (worker.joinable())
2382+ worker.join();
2383+}
2384+
2385+std::function<void(std::function<void()>)> culs::Runtime::to_dispatcher_functional()
2386+{
2387+ // We have to make sure that we stay alive for as long as
2388+ // calling code requires the dispatcher to work.
2389+ auto sp = shared_from_this();
2390+ return [sp](std::function<void()> task)
2391+ {
2392+ sp->strand_.post(task);
2393+ };
2394+}
2395+
2396+boost::asio::io_service& culs::Runtime::service()
2397+{
2398+ return service_;
2399+}
2400
2401=== added file 'src/location_service/com/ubuntu/location/service/runtime.h'
2402--- src/location_service/com/ubuntu/location/service/runtime.h 1970-01-01 00:00:00 +0000
2403+++ src/location_service/com/ubuntu/location/service/runtime.h 2016-04-05 17:17:30 +0000
2404@@ -0,0 +1,90 @@
2405+/*
2406+ * Copyright © 2015 Canonical Ltd.
2407+ *
2408+ * This program is free software: you can redistribute it and/or modify it
2409+ * under the terms of the GNU Lesser General Public License version 3,
2410+ * as published by the Free Software Foundation.
2411+ *
2412+ * This program is distributed in the hope that it will be useful,
2413+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2414+ * MERCHANTABILITY or FITNESS FOR A PARTIlocationAR PURPOSE. See the
2415+ * GNU Lesser General Public License for more details.
2416+ *
2417+ * You should have received a copy of the GNU Lesser General Public License
2418+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2419+ *
2420+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
2421+ */
2422+#ifndef COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
2423+#define COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
2424+
2425+#include <boost/asio.hpp>
2426+
2427+#include <functional>
2428+#include <memory>
2429+#include <thread>
2430+#include <vector>
2431+
2432+#include <cstdint>
2433+
2434+namespace com
2435+{
2436+namespace ubuntu
2437+{
2438+namespace location
2439+{
2440+namespace service
2441+{
2442+// We bundle our "global" runtime dependencies here, specifically
2443+// a dispatcher to decouple multiple in-process providers from one
2444+// another , forcing execution to a well known set of threads.
2445+class Runtime : public std::enable_shared_from_this<Runtime>
2446+{
2447+public:
2448+ // Our default concurrency setup.
2449+ static constexpr const std::uint32_t worker_threads = 2;
2450+
2451+ // create returns a Runtime instance with pool_size worker threads
2452+ // executing the underlying service.
2453+ static std::shared_ptr<Runtime> create(std::uint32_t pool_size = worker_threads);
2454+
2455+ Runtime(const Runtime&) = delete;
2456+ Runtime(Runtime&&) = delete;
2457+ // Tears down the runtime, stopping all worker threads.
2458+ ~Runtime() noexcept(true);
2459+ Runtime& operator=(const Runtime&) = delete;
2460+ Runtime& operator=(Runtime&&) = delete;
2461+
2462+ // start executes the underlying io_service on a thread pool with
2463+ // the size configured at creation time.
2464+ void start();
2465+
2466+ // stop cleanly shuts down a Runtime instance,
2467+ // joining all worker threads.
2468+ void stop();
2469+
2470+ // to_dispatcher_functional returns a function for integration
2471+ // with components that expect a dispatcher for operation.
2472+ std::function<void(std::function<void()>)> to_dispatcher_functional();
2473+
2474+ // service returns the underlying boost::asio::io_service that is executed
2475+ // by the Runtime.
2476+ boost::asio::io_service& service();
2477+
2478+private:
2479+ // Runtime constructs a new instance, firing up pool_size
2480+ // worker threads.
2481+ Runtime(std::uint32_t pool_size);
2482+
2483+ std::uint32_t pool_size_;
2484+ boost::asio::io_service service_;
2485+ boost::asio::io_service::strand strand_;
2486+ boost::asio::io_service::work keep_alive_;
2487+ std::vector<std::thread> workers_;
2488+};
2489+}
2490+}
2491+}
2492+}
2493+
2494+#endif // COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
2495
2496=== modified file 'src/location_service/com/ubuntu/location/service/session/skeleton.cpp'
2497--- src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2014-08-14 20:31:09 +0000
2498+++ src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2016-04-05 17:17:30 +0000
2499@@ -283,7 +283,13 @@
2500 VLOG(10) << __PRETTY_FUNCTION__;
2501 try
2502 {
2503- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdatePosition, void>(position);
2504+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdatePosition, void>([](const core::dbus::Result<void>& result)
2505+ {
2506+ if (result.is_error())
2507+ {
2508+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
2509+ }
2510+ }, position);
2511 } catch(const std::exception&)
2512 {
2513 // We consider the session to be dead once we hit an exception here.
2514@@ -300,7 +306,13 @@
2515 VLOG(10) << __PRETTY_FUNCTION__;
2516 try
2517 {
2518- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateHeading, void>(heading);
2519+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateHeading, void>([](const core::dbus::Result<void>& result)
2520+ {
2521+ if (result.is_error())
2522+ {
2523+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
2524+ }
2525+ }, heading);
2526 } catch(const std::exception&)
2527 {
2528 // We consider the session to be dead once we hit an exception here.
2529@@ -317,7 +329,13 @@
2530 VLOG(10) << __PRETTY_FUNCTION__;
2531 try
2532 {
2533- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateVelocity, void>(velocity);
2534+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateVelocity, void>([](const core::dbus::Result<void>& result)
2535+ {
2536+ if (result.is_error())
2537+ {
2538+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
2539+ }
2540+ }, velocity);
2541 } catch(const std::exception&)
2542 {
2543 // We consider the session to be dead once we hit an exception here.
2544
2545=== modified file 'src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp'
2546--- src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp 2014-09-19 14:36:51 +0000
2547+++ src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp 2016-04-05 17:17:30 +0000
2548@@ -146,7 +146,7 @@
2549 return service::PermissionManager::Result::rejected;
2550 }
2551
2552- std::string description = i18n::tr("%1% wants to access your current location.");
2553+ std::string description = i18n::tr("wants to access your current location.");
2554
2555 core::trust::Agent::RequestParameters params
2556 {
2557
2558=== modified file 'src/location_service/com/ubuntu/location/time_based_update_policy.cpp'
2559--- src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2015-04-23 21:30:04 +0000
2560+++ src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2016-04-05 17:17:30 +0000
2561@@ -53,8 +53,9 @@
2562 {
2563 // if the update has happened within a reasonable amount of time we will just use it if it is more accurate
2564 // that the previous one.
2565- use_new_update = last_position_update.value.accuracy.horizontal && update.value.accuracy.horizontal
2566- && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal;
2567+ use_new_update = !last_position_update.value.accuracy.horizontal ||
2568+ (update.value.accuracy.horizontal
2569+ && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal);
2570 }
2571
2572 if (use_new_update)
2573@@ -118,4 +119,4 @@
2574
2575 }
2576 }
2577-}
2578\ No newline at end of file
2579+}
2580
2581=== modified file 'tests/CMakeLists.txt'
2582--- tests/CMakeLists.txt 2015-04-23 17:04:09 +0000
2583+++ tests/CMakeLists.txt 2016-04-05 17:17:30 +0000
2584@@ -92,6 +92,7 @@
2585 LOCATION_SERVICE_ADD_TEST(provider_test provider_test.cpp)
2586 LOCATION_SERVICE_ADD_TEST(wgs84_test wgs84_test.cpp)
2587 LOCATION_SERVICE_ADD_TEST(trust_store_permission_manager_test trust_store_permission_manager_test.cpp)
2588+LOCATION_SERVICE_ADD_TEST(runtime_test runtime_test.cpp)
2589
2590 # Provider-specific test-cases go here.
2591 if (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
2592@@ -124,3 +125,4 @@
2593
2594 LOCATION_SERVICE_ADD_TEST(remote_provider_test remote_provider_test.cpp)
2595 LOCATION_SERVICE_ADD_TEST(espoo_provider_test espoo_provider_test.cpp)
2596+LOCATION_SERVICE_ADD_TEST(delayed_service_test delayed_service_test.cpp)
2597
2598=== modified file 'tests/acceptance_tests.cpp'
2599--- tests/acceptance_tests.cpp 2015-02-13 13:19:18 +0000
2600+++ tests/acceptance_tests.cpp 2016-04-05 17:17:30 +0000
2601@@ -38,12 +38,14 @@
2602 #include <com/ubuntu/location/service/stub.h>
2603
2604 #include <core/dbus/announcer.h>
2605+#include <core/dbus/bus.h>
2606 #include <core/dbus/fixture.h>
2607 #include <core/dbus/resolver.h>
2608
2609 #include <core/dbus/asio/executor.h>
2610
2611 #include <core/posix/signal.h>
2612+#include <core/posix/this_process.h>
2613
2614 #include <core/testing/cross_process_sync.h>
2615 #include <core/testing/fork_and_run.h>
2616@@ -663,6 +665,110 @@
2617 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
2618 }
2619
2620+TEST_F(LocationServiceStandalone, NewSessionsGetLastKnownPosition)
2621+{
2622+ core::testing::CrossProcessSync sync_start;
2623+
2624+ auto server = [this, &sync_start]()
2625+ {
2626+ SCOPED_TRACE("Server");
2627+
2628+ auto trap = core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_term});
2629+ trap->signal_raised().connect([trap](core::posix::Signal)
2630+ {
2631+ trap->stop();
2632+ });
2633+
2634+ auto incoming = session_bus();
2635+ auto outgoing = session_bus();
2636+
2637+ incoming->install_executor(core::dbus::asio::make_executor(incoming));
2638+ outgoing->install_executor(core::dbus::asio::make_executor(outgoing));
2639+
2640+ auto dummy = new DummyProvider();
2641+ cul::Provider::Ptr helper(dummy);
2642+
2643+ cul::service::DefaultConfiguration config;
2644+ cul::service::Implementation::Configuration configuration
2645+ {
2646+ incoming,
2647+ outgoing,
2648+ config.the_engine(config.the_provider_set(helper), config.the_provider_selection_policy(), null_settings()),
2649+ config.the_permission_manager(incoming),
2650+ cul::service::Harvester::Configuration
2651+ {
2652+ cul::connectivity::platform_default_manager(),
2653+ std::make_shared<NullReporter>()
2654+ }
2655+ };
2656+ auto location_service = std::make_shared<cul::service::Implementation>(configuration);
2657+
2658+ configuration.engine->updates.last_known_location.set(reference_position_update);
2659+ std::thread t1{[incoming](){incoming->run();}};
2660+ std::thread t2{[outgoing](){outgoing->run();}};
2661+
2662+ sync_start.try_signal_ready_for(std::chrono::milliseconds{500});
2663+
2664+ trap->run();
2665+
2666+ incoming->stop();
2667+ outgoing->stop();
2668+
2669+ if (t1.joinable())
2670+ t1.join();
2671+
2672+ if (t2.joinable())
2673+ t2.join();
2674+
2675+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
2676+ };
2677+
2678+ auto client = [this, &sync_start]()
2679+ {
2680+ SCOPED_TRACE("Client");
2681+
2682+ EXPECT_EQ(1, sync_start.wait_for_signal_ready_for(std::chrono::milliseconds{500}));
2683+
2684+ auto bus = session_bus();
2685+ bus->install_executor(dbus::asio::make_executor(bus));
2686+ std::thread t{[bus](){bus->run();}};
2687+
2688+ auto location_service = dbus::resolve_service_on_bus<
2689+ cul::service::Interface,
2690+ cul::service::Stub>(bus);
2691+
2692+ auto s1 = location_service->create_session_for_criteria(cul::Criteria{});
2693+
2694+ std::cout << "Successfully created session" << std::endl;
2695+
2696+ cul::Update<cul::Position> position;
2697+ auto c1 = s1->updates().position.changed().connect(
2698+ [&](const cul::Update<cul::Position>& new_position) {
2699+ std::cout << "On position updated: " << new_position << std::endl;
2700+ position = new_position;
2701+ });
2702+
2703+ std::cout << "Created event connections, starting updates..." << std::endl;
2704+
2705+ s1->updates().position_status = culss::Interface::Updates::Status::enabled;
2706+
2707+ std::cout << "done" << std::endl;
2708+
2709+ std::this_thread::sleep_for(std::chrono::milliseconds{1000});
2710+
2711+ bus->stop();
2712+
2713+ if (t.joinable())
2714+ t.join();
2715+
2716+ EXPECT_EQ(reference_position_update, position);
2717+
2718+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
2719+ };
2720+
2721+ EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
2722+}
2723+
2724 namespace
2725 {
2726 struct LocationServiceStandaloneLoad : public LocationServiceStandalone
2727@@ -708,7 +814,7 @@
2728
2729 options.add(Keys::update_period,
2730 "Update period length for dummy::Provider setup.",
2731- std::uint32_t{100});
2732+ std::uint32_t{10});
2733
2734 options.add(Keys::client_count,
2735 "Number of clients that should be fired up.",
2736@@ -761,6 +867,8 @@
2737 };
2738 }
2739
2740+#include "did_finish_successfully.h"
2741+
2742 TEST_F(LocationServiceStandaloneLoad, MultipleClientsConnectingAndDisconnectingWorks)
2743 {
2744 EXPECT_TRUE(trust_store_is_set_up_for_testing);
2745@@ -801,8 +909,8 @@
2746 };
2747
2748 cul::service::Daemon::Configuration config;
2749- config.incoming = session_bus();
2750- config.outgoing = session_bus();
2751+ config.incoming = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
2752+ config.outgoing = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
2753 config.is_testing_enabled = false;
2754 config.providers =
2755 {
2756@@ -829,7 +937,7 @@
2757 status;
2758 }, core::posix::StandardStream::empty);
2759
2760- std::this_thread::sleep_for(std::chrono::seconds{2});
2761+ std::this_thread::sleep_for(std::chrono::seconds{15});
2762
2763 auto client = [this]()
2764 {
2765@@ -957,17 +1065,11 @@
2766 {
2767 VLOG(1) << "Stopping client...: " << client.pid();
2768 client.send_signal_or_throw(core::posix::Signal::sig_term);
2769- auto result = client.wait_for(core::posix::wait::Flags::untraced);
2770-
2771- EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
2772- EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
2773+ EXPECT_TRUE(did_finish_successfully(client.wait_for(core::posix::wait::Flags::untraced)));
2774 }
2775
2776 VLOG(1) << "Cleaned up clients, shutting down the service...";
2777
2778 server.send_signal_or_throw(core::posix::Signal::sig_term);
2779- auto result = server.wait_for(core::posix::wait::Flags::untraced);
2780-
2781- EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
2782- EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
2783+ EXPECT_TRUE(did_finish_successfully(server.wait_for(core::posix::wait::Flags::untraced)));
2784 }
2785
2786=== added file 'tests/delayed_service_test.cpp'
2787--- tests/delayed_service_test.cpp 1970-01-01 00:00:00 +0000
2788+++ tests/delayed_service_test.cpp 2016-04-05 17:17:30 +0000
2789@@ -0,0 +1,193 @@
2790+/*
2791+ * Copyright © 2014 Canonical Ltd.
2792+ *
2793+ * This program is free software: you can redistribute it and/or modify it
2794+ * under the terms of the GNU Lesser General Public License version 3,
2795+ * as published by the Free Software Foundation.
2796+ *
2797+ * This program is distributed in the hope that it will be useful,
2798+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2799+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2800+ * GNU Lesser General Public License for more details.
2801+ *
2802+ * You should have received a copy of the GNU Lesser General Public License
2803+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2804+ *
2805+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
2806+ * Scott Sweeny <scott.sweeny@canonical.com>
2807+ */
2808+
2809+#include <com/ubuntu/location/service/daemon.h>
2810+#include <com/ubuntu/location/service/provider_daemon.h>
2811+#include <com/ubuntu/location/providers/remote/provider.h>
2812+
2813+#include <com/ubuntu/location/service/stub.h>
2814+
2815+#include <com/ubuntu/location/position.h>
2816+#include <com/ubuntu/location/update.h>
2817+
2818+#include <core/dbus/fixture.h>
2819+
2820+#include <core/dbus/asio/executor.h>
2821+
2822+#include <core/posix/fork.h>
2823+#include <core/posix/signal.h>
2824+#include <core/posix/this_process.h>
2825+
2826+#include "did_finish_successfully.h"
2827+#include "mock_event_receiver.h"
2828+
2829+#include <gmock/gmock.h>
2830+
2831+namespace location = com::ubuntu::location;
2832+namespace remote = com::ubuntu::location::providers::remote;
2833+
2834+namespace
2835+{
2836+struct DelayedServiceTest : public core::dbus::testing::Fixture, public ::testing::WithParamInterface<int>
2837+{
2838+
2839+};
2840+}
2841+
2842+TEST_P(DelayedServiceTest, AClientReceivesUpdatesFromADelayedProvider)
2843+{
2844+ auto oopp = core::posix::fork([this]()
2845+ {
2846+ auto bus = session_bus();
2847+
2848+ // Pass the delay value to the provider
2849+ char delay[50];
2850+ sprintf(delay, "--dummy::DelayedProvider::DelayInMs=%d", GetParam());
2851+
2852+ const char* argv[] =
2853+ {
2854+ "--bus", "session", // 2
2855+ "--service-name", "com.ubuntu.location.providers.Dummy", // 4
2856+ "--service-path", "/com/ubuntu/location/providers/Dummy", // 6
2857+ "--provider", "dummy::DelayedProvider", // 8
2858+ delay // 9
2859+ };
2860+
2861+ auto dbus_connection_factory = [bus](core::dbus::WellKnownBus)
2862+ {
2863+ return bus;
2864+ };
2865+
2866+ return static_cast<core::posix::exit::Status>(
2867+ location::service::ProviderDaemon::main(
2868+ location::service::ProviderDaemon::Configuration::from_command_line_args(
2869+ 9, argv, dbus_connection_factory)));
2870+ }, core::posix::StandardStream::empty);
2871+
2872+ std::this_thread::sleep_for(std::chrono::milliseconds{250});
2873+
2874+ auto service = core::posix::fork([this]()
2875+ {
2876+ core::posix::this_process::env::set_or_throw(
2877+ "TRUST_STORE_PERMISSION_MANAGER_IS_RUNNING_UNDER_TESTING",
2878+ "1");
2879+
2880+ const char* argv[] =
2881+ {
2882+ "--bus", "session", // 2
2883+ "--provider", "remote::Provider", // 4
2884+ "--remote::Provider::bus=session_with_address_from_env", // 5
2885+ "--remote::Provider::name=com.ubuntu.location.providers.Dummy", // 6
2886+ "--remote::Provider::path=/com/ubuntu/location/providers/Dummy" // 7
2887+ };
2888+
2889+ // The daemon instance requires two bus instances.
2890+ auto dbus_connection_factory = [this](core::dbus::WellKnownBus)
2891+ {
2892+ return session_bus();
2893+ };
2894+
2895+ return static_cast<core::posix::exit::Status>(
2896+ location::service::Daemon::main(
2897+ location::service::Daemon::Configuration::from_command_line_args(
2898+ 7, argv, dbus_connection_factory)));
2899+ }, core::posix::StandardStream::empty);
2900+
2901+ // Wait to setup the client until the service is up
2902+ std::this_thread::sleep_for(std::chrono::milliseconds{250 + GetParam()});
2903+
2904+ auto client = core::posix::fork([this]()
2905+ {
2906+ using namespace ::testing;
2907+
2908+ auto trap = core::posix::trap_signals_for_all_subsequent_threads(
2909+ {
2910+ core::posix::Signal::sig_term,
2911+ core::posix::Signal::sig_int
2912+ });
2913+
2914+ trap->signal_raised().connect([trap](const core::posix::Signal&)
2915+ {
2916+ trap->stop();
2917+ });
2918+
2919+ auto bus = session_bus();
2920+ bus->install_executor(core::dbus::asio::make_executor(bus));
2921+
2922+ std::thread worker
2923+ {
2924+ [bus]() { bus->run(); }
2925+ };
2926+
2927+ MockEventReceiver receiver;
2928+ EXPECT_CALL(receiver, position_update_received(_)).Times(AtLeast(1));
2929+ EXPECT_CALL(receiver, heading_update_received(_)).Times(AtLeast(1));
2930+ EXPECT_CALL(receiver, velocity_update_received(_)).Times(AtLeast(1));
2931+
2932+ com::ubuntu::location::service::Stub service{bus};
2933+
2934+ auto session = service.create_session_for_criteria(location::Criteria{});
2935+
2936+ session->updates().position.changed().connect([&receiver](location::Update<location::Position> pos)
2937+ {
2938+ receiver.position_update_received(pos);
2939+ });
2940+
2941+ session->updates().heading.changed().connect([&receiver](location::Update<location::Heading> heading)
2942+ {
2943+ receiver.heading_update_received(heading);
2944+ });
2945+
2946+ session->updates().velocity.changed().connect([&receiver](location::Update<location::Velocity> velocity)
2947+ {
2948+ receiver.velocity_update_received(velocity);
2949+ });
2950+
2951+ session->updates().position_status = location::service::session::Interface::Updates::Status::enabled;
2952+ session->updates().velocity_status = location::service::session::Interface::Updates::Status::enabled;
2953+ session->updates().heading_status = location::service::session::Interface::Updates::Status::enabled;
2954+
2955+ trap->run();
2956+
2957+ bus->stop();
2958+
2959+ if (worker.joinable())
2960+ worker.join();
2961+
2962+ return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure :
2963+ core::posix::exit::Status::success;
2964+ }, core::posix::StandardStream::empty);
2965+
2966+ std::this_thread::sleep_for(std::chrono::milliseconds{4000});
2967+
2968+ std::cout << "Shutting down client" << std::endl;
2969+ client.send_signal_or_throw(core::posix::Signal::sig_term);
2970+ EXPECT_TRUE(did_finish_successfully(client.wait_for(core::posix::wait::Flags::untraced)));
2971+
2972+ std::cout << "Shutting down service" << std::endl;
2973+ service.send_signal_or_throw(core::posix::Signal::sig_term);
2974+ EXPECT_TRUE(did_finish_successfully(service.wait_for(core::posix::wait::Flags::untraced)));
2975+
2976+ std::cout << "Shutting down oopp" << std::endl;
2977+ oopp.send_signal_or_throw(core::posix::Signal::sig_term);
2978+ EXPECT_TRUE(did_finish_successfully(oopp.wait_for(core::posix::wait::Flags::untraced)));
2979+}
2980+
2981+INSTANTIATE_TEST_CASE_P(ServiceDelays, DelayedServiceTest,
2982+ ::testing::Values(0, 250, 500, 1000, 2000, 5000, 10000));
2983
2984=== modified file 'tests/engine_test.cpp'
2985--- tests/engine_test.cpp 2015-01-21 20:04:56 +0000
2986+++ tests/engine_test.cpp 2016-04-05 17:17:30 +0000
2987@@ -154,9 +154,9 @@
2988 EXPECT_CALL(*provider, on_reference_velocity_updated(_)).Times(1);
2989
2990 engine.configuration.wifi_and_cell_id_reporting_state = location::WifiAndCellIdReportingState::on;
2991- engine.updates.reference_location = location::Update<location::Position>{};
2992- engine.updates.reference_heading = location::Update<location::Heading>{};
2993- engine.updates.reference_velocity = location::Update<location::Velocity>{};
2994+ engine.updates.last_known_location = location::Update<location::Position>{};
2995+ engine.updates.last_known_heading = location::Update<location::Heading>{};
2996+ engine.updates.last_known_velocity = location::Update<location::Velocity>{};
2997 }
2998
2999 /* TODO(tvoss): We have to disable these tests as the MP is being refactored to not break ABI.
3000@@ -273,13 +273,9 @@
3001 auto selection_policy = std::make_shared<NiceMock<MockProviderSelectionPolicy>>();
3002
3003 EXPECT_CALL(*settings, has_value_for_key(_))
3004- .Times(3)
3005+ .Times(2)
3006 .WillRepeatedly(Return(true));
3007 EXPECT_CALL(*settings, get_string_for_key_or_throw(
3008- location::Engine::Configuration::Keys::satellite_based_positioning_state))
3009- .Times(1)
3010- .WillRepeatedly(Return(ss_satellite_based_positioning_state.str()));
3011- EXPECT_CALL(*settings, get_string_for_key_or_throw(
3012 location::Engine::Configuration::Keys::wifi_and_cell_id_reporting_state))
3013 .Times(1)
3014 .WillRepeatedly(Return(ss_wifi_and_cell_id_reporting_state.str()));
3015@@ -299,11 +295,6 @@
3016 auto selection_policy = std::make_shared<NiceMock<MockProviderSelectionPolicy>>();
3017
3018 EXPECT_CALL(*settings, set_string_for_key(
3019- location::Engine::Configuration::Keys::satellite_based_positioning_state,
3020- _))
3021- .Times(1)
3022- .WillRepeatedly(Return(true));
3023- EXPECT_CALL(*settings, set_string_for_key(
3024 location::Engine::Configuration::Keys::wifi_and_cell_id_reporting_state,
3025 _))
3026 .Times(1)
3027
3028=== modified file 'tests/gps_provider_test.cpp'
3029--- tests/gps_provider_test.cpp 2015-01-12 08:41:14 +0000
3030+++ tests/gps_provider_test.cpp 2016-04-05 17:17:30 +0000
3031@@ -48,6 +48,31 @@
3032
3033 namespace
3034 {
3035+
3036+struct MockHardwareGps
3037+{
3038+ MockHardwareGps()
3039+ {
3040+ instance_ = this;
3041+ }
3042+ ~MockHardwareGps()
3043+ {
3044+ instance_ = nullptr;
3045+ }
3046+
3047+ MOCK_METHOD5(set_position_mode, bool(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t));
3048+ MOCK_METHOD3(inject_time, void(int64_t, int64_t, int));
3049+
3050+ static MockHardwareGps *mocked(UHardwareGps self) {
3051+ return reinterpret_cast<MockHardwareGps*>(self);
3052+ }
3053+ static MockHardwareGps *instance() { return instance_; }
3054+
3055+ static MockHardwareGps *instance_;
3056+};
3057+
3058+MockHardwareGps *MockHardwareGps::instance_ = nullptr;
3059+
3060 struct UpdateTrap
3061 {
3062 MOCK_METHOD1(on_position_updated, void(const location::Position&));
3063@@ -211,6 +236,42 @@
3064
3065 }
3066
3067+/* Mock the hardware GPS platform API: the methods defined here will be invoked
3068+ * instead of those exported by the system library.
3069+ * We redefine these methods using the MockHardwareGps class above, which is
3070+ * implemented using google-mock. This effectively allows us to test that the
3071+ * right calls to the platform API are made.
3072+ */
3073+UHardwareGps
3074+u_hardware_gps_new(UHardwareGpsParams *)
3075+{
3076+ using namespace ::testing;
3077+
3078+ return reinterpret_cast<UHardwareGps>(MockHardwareGps::instance());
3079+}
3080+
3081+void
3082+u_hardware_gps_delete(UHardwareGps)
3083+{
3084+}
3085+
3086+bool
3087+u_hardware_gps_set_position_mode(UHardwareGps self, uint32_t mode, uint32_t recurrence,
3088+ uint32_t min_interval, uint32_t preferred_accuracy,
3089+ uint32_t preferred_time)
3090+{
3091+ MockHardwareGps *thiz = MockHardwareGps::mocked(self);
3092+ return thiz->set_position_mode(mode, recurrence, min_interval,
3093+ preferred_accuracy, preferred_time);
3094+}
3095+
3096+void
3097+u_hardware_gps_inject_time(UHardwareGps self, int64_t time, int64_t time_reference, int uncertainty)
3098+{
3099+ MockHardwareGps* thiz = MockHardwareGps::mocked(self);
3100+ return thiz->inject_time(time, time_reference, uncertainty);
3101+}
3102+
3103 TEST(AndroidGpsXtraDownloader, reading_configuration_from_valid_conf_file_works)
3104 {
3105 std::stringstream ss{gps_conf};
3106@@ -261,6 +322,28 @@
3107 provider.on_reference_location_updated(pos);
3108 }
3109
3110+TEST(GpsProvider, time_requests_inject_current_time_into_the_hal)
3111+{
3112+ using namespace ::testing;
3113+
3114+ NiceMock<MockHardwareGps> hardwareGps;
3115+
3116+ gps::android::HardwareAbstractionLayer::Configuration configuration;
3117+ gps::android::HardwareAbstractionLayer hal(configuration);
3118+ std::shared_ptr<gps::HardwareAbstractionLayer> hal_ptr(&hal, [](gps::HardwareAbstractionLayer*){});
3119+
3120+ gps::Provider provider(hal_ptr);
3121+ int64_t time = 0;
3122+ EXPECT_CALL(hardwareGps, inject_time(_, _, 0)).Times(1).WillOnce(SaveArg<0>(&time));
3123+
3124+ auto t0 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
3125+
3126+ gps::android::HardwareAbstractionLayer::on_request_utc_time(&hal);
3127+
3128+ auto t1 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
3129+ EXPECT_THAT(time, AllOf(Ge(t0.count()), Le(t1.count())));
3130+}
3131+
3132 TEST(GpsProvider, updates_from_hal_are_passed_on_by_the_provider)
3133 {
3134 using namespace ::testing;
3135
3136=== added file 'tests/mock_event_receiver.h'
3137--- tests/mock_event_receiver.h 1970-01-01 00:00:00 +0000
3138+++ tests/mock_event_receiver.h 2016-04-05 17:17:30 +0000
3139@@ -0,0 +1,35 @@
3140+/*
3141+ * Copyright © 2015 Canonical Ltd.
3142+ *
3143+ * This program is free software: you can redistribute it and/or modify it
3144+ * under the terms of the GNU Lesser General Public License version 3,
3145+ * as published by the Free Software Foundation.
3146+ *
3147+ * This program is distributed in the hope that it will be useful,
3148+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3149+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3150+ * GNU Lesser General Public License for more details.
3151+ *
3152+ * You should have received a copy of the GNU Lesser General Public License
3153+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3154+ *
3155+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
3156+ * Scott Sweeny <scott.sweeny@canonical.com>
3157+ */
3158+#ifndef MOCK_EVENT_RECEIVER_H_
3159+#define MOCK_EVENT_RECEIVER_H_
3160+
3161+#include <com/ubuntu/location/update.h>
3162+
3163+#include <gmock/gmock.h>
3164+
3165+namespace location = com::ubuntu::location;
3166+
3167+struct MockEventReceiver
3168+{
3169+ MOCK_METHOD1(position_update_received, void(const location::Update<location::Position>&));
3170+ MOCK_METHOD1(heading_update_received, void(const location::Update<location::Heading>&));
3171+ MOCK_METHOD1(velocity_update_received, void(const location::Update<location::Velocity>&));
3172+};
3173+
3174+#endif // MOCK_EVENT_RECEIVER_H_
3175
3176=== modified file 'tests/position_test.cpp'
3177--- tests/position_test.cpp 2014-06-20 07:40:34 +0000
3178+++ tests/position_test.cpp 2016-04-05 17:17:30 +0000
3179@@ -40,7 +40,7 @@
3180 cul::wgs84::Latitude{},
3181 cul::wgs84::Longitude{},
3182 cul::wgs84::Altitude{}};
3183- EXPECT_TRUE(p.altitude);
3184+ EXPECT_TRUE(p.altitude ? true : false);
3185 }
3186
3187 #include <com/ubuntu/location/codec.h>
3188
3189=== modified file 'tests/remote_providerd_test.cpp'
3190--- tests/remote_providerd_test.cpp 2014-10-27 21:58:16 +0000
3191+++ tests/remote_providerd_test.cpp 2016-04-05 17:17:30 +0000
3192@@ -31,6 +31,7 @@
3193 #include <core/posix/fork.h>
3194
3195 #include "did_finish_successfully.h"
3196+#include "mock_event_receiver.h"
3197
3198 #include <gmock/gmock.h>
3199
3200@@ -38,13 +39,6 @@
3201
3202 namespace
3203 {
3204-struct MockEventReceiver
3205-{
3206- MOCK_METHOD1(position_update_received, void(const location::Update<location::Position>&));
3207- MOCK_METHOD1(heading_update_received, void(const location::Update<location::Heading>&));
3208- MOCK_METHOD1(velocity_update_received, void(const location::Update<location::Velocity>&));
3209-};
3210-
3211 struct RemoteProviderdTest : public core::dbus::testing::Fixture
3212 {
3213
3214
3215=== added file 'tests/runtime_test.cpp'
3216--- tests/runtime_test.cpp 1970-01-01 00:00:00 +0000
3217+++ tests/runtime_test.cpp 2016-04-05 17:17:30 +0000
3218@@ -0,0 +1,118 @@
3219+/*
3220+ * Copyright © 2015Canonical Ltd.
3221+ *
3222+ * This program is free software: you can redistribute it and/or modify it
3223+ * under the terms of the GNU Lesser General Public License version 3,
3224+ * as published by the Free Software Foundation.
3225+ *
3226+ * This program is distributed in the hope that it will be useful,
3227+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3228+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3229+ * GNU Lesser General Public License for more details.
3230+ *
3231+ * You should have received a copy of the GNU Lesser General Public License
3232+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3233+ *
3234+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
3235+ */
3236+#include <com/ubuntu/location/service/runtime.h>
3237+
3238+#include <gtest/gtest.h>
3239+
3240+#include <condition_variable>
3241+#include <thread>
3242+
3243+namespace culs = com::ubuntu::location::service;
3244+
3245+TEST(Runtime, cleanly_shuts_down_threads)
3246+{
3247+ culs::Runtime::create();
3248+}
3249+
3250+TEST(Runtime, executes_service)
3251+{
3252+ std::mutex m;
3253+ std::unique_lock<std::mutex> ul{m};
3254+ std::condition_variable wc;
3255+
3256+ bool signaled = false;
3257+
3258+ auto rt = culs::Runtime::create();
3259+ rt->start();
3260+ boost::asio::deadline_timer timer{rt->service(), boost::posix_time::milliseconds(500)};
3261+ timer.async_wait([&wc, &signaled](const boost::system::error_code&)
3262+ {
3263+ signaled = true;
3264+ wc.notify_all();
3265+ });
3266+
3267+ auto result = wc.wait_for(ul, std::chrono::seconds{1}, [&signaled]() { return signaled; });
3268+ EXPECT_TRUE(result);
3269+}
3270+
3271+TEST(Runtime, catches_exceptions_thrown_from_handlers)
3272+{
3273+ std::mutex m;
3274+ std::unique_lock<std::mutex> ul{m};
3275+ std::condition_variable wc;
3276+
3277+ bool signaled = false;
3278+
3279+ auto rt = culs::Runtime::create();
3280+ rt->start();
3281+ boost::asio::deadline_timer fast{rt->service(), boost::posix_time::milliseconds(100)};
3282+ fast.async_wait([](const boost::system::error_code&)
3283+ {
3284+ throw std::runtime_error{"Should not propagate"};
3285+ });
3286+
3287+ boost::asio::deadline_timer slow{rt->service(), boost::posix_time::milliseconds(500)};
3288+ slow.async_wait([&wc, &signaled](const boost::system::error_code&)
3289+ {
3290+ signaled = true;
3291+ wc.notify_all();
3292+ });
3293+
3294+ auto result = wc.wait_for(ul, std::chrono::seconds{1}, [&signaled]() { return signaled; });
3295+ EXPECT_TRUE(result);
3296+}
3297+
3298+// sets_up_pool_of_threads ensures that the pool size
3299+// passed to the Runtime on construction is honored. The idea is simple:
3300+// We set up two deadline timers, fast and slow. fast fires before slow,
3301+// with fast blocking in a wait on a common condition_variable. When slow
3302+// fires, it notifies the condition variable, thereby unblocking the handler of fast,
3303+// enabling clean shutdown without errors and timeouts. This only works if the
3304+// pool contains at least 2 threads. Otherwise, the handler of slow would not be executed
3305+// until the handler of fast times out in the wait, marking the test as failed.
3306+TEST(Runtime, sets_up_pool_of_threads)
3307+{
3308+ struct State
3309+ {
3310+ bool signaled{false};
3311+ std::mutex m;
3312+ std::condition_variable wc;
3313+ };
3314+
3315+ auto state = std::make_shared<State>();
3316+
3317+ auto rt = culs::Runtime::create(2);
3318+ rt->start();
3319+ boost::asio::deadline_timer fast{rt->service(), boost::posix_time::milliseconds(100)};
3320+ fast.async_wait([state](const boost::system::error_code&)
3321+ {
3322+ std::unique_lock<std::mutex> ul{state->m};
3323+ EXPECT_TRUE(state->wc.wait_for(ul, std::chrono::seconds{1}, [state]() { return state->signaled; }));
3324+ });
3325+
3326+ boost::asio::deadline_timer slow{rt->service(), boost::posix_time::milliseconds(500)};
3327+ slow.async_wait([state](const boost::system::error_code&)
3328+ {
3329+ state->signaled = true;
3330+ state->wc.notify_all();
3331+ });
3332+
3333+ std::unique_lock<std::mutex> ul{state->m};
3334+ auto result = state->wc.wait_for(ul, std::chrono::seconds{1}, [state]() { return state->signaled; });
3335+ EXPECT_TRUE(result);
3336+}
3337
3338=== added directory 'tools'
3339=== added file 'tools/CMakeLists.txt'
3340--- tools/CMakeLists.txt 1970-01-01 00:00:00 +0000
3341+++ tools/CMakeLists.txt 2016-04-05 17:17:30 +0000
3342@@ -0,0 +1,1 @@
3343+configure_file(symbol_diff.in symbol_diff)
3344
3345=== added file 'tools/symbol_diff.in'
3346--- tools/symbol_diff.in 1970-01-01 00:00:00 +0000
3347+++ tools/symbol_diff.in 2016-04-05 17:17:30 +0000
3348@@ -0,0 +1,70 @@
3349+#! /usr/bin/env python3
3350+
3351+#
3352+# Copyright (C) 2014 Canonical Ltd
3353+#
3354+# This program is free software: you can redistribute it and/or modify
3355+# it under the terms of the GNU Lesser General Public License version 3 as
3356+# published by the Free Software Foundation.
3357+#
3358+# This program is distributed in the hope that it will be useful,
3359+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3360+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3361+# GNU Lesser General Public License for more details.
3362+#
3363+# You should have received a copy of the GNU Lesser General Public License
3364+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3365+#
3366+# Authored by: Michi Henning <michi.henning@canonical.com>
3367+#
3368+
3369+import re
3370+import subprocess
3371+
3372+OLD_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.symbols'
3373+NEW_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@/DEBIAN/symbols'
3374+
3375+def run():
3376+ old_regex = re.compile(r'^ (\(.*\))"(.*)" (.*)$')
3377+
3378+ old_syms = {} # Dictionary containing symbol -> ( tag, version )
3379+ with open(OLD_FILE, encoding='utf=8') as file:
3380+ file.readline() # Skip first line, which is the library name and version
3381+ for line in file:
3382+ mo = old_regex.match(line)
3383+ if mo:
3384+ old_syms[mo.group(2)] = ( mo.group(1), mo.group(3) )
3385+ else:
3386+ raise Exception('Invalid input line in ' + OLD_FILE + ': ' + line)
3387+
3388+ new_regex = re.compile(r'^ (.*) .+$')
3389+
3390+ # Run the new symbols file through "c++filt | sort | uniq". We need
3391+ # the sort | uniq because, otherwise, we end up with duplicate demangled symbols.
3392+ with open(NEW_FILE) as infile, open('new_symbols', 'w') as outfile:
3393+ p = subprocess.Popen(['c++filt | sort | uniq'], shell=True, stdin=infile, stdout=subprocess.PIPE)
3394+
3395+ # For each symbol, if it is in the old dictionary, output the tags from the original
3396+ # symbol file, followed by the symbol and version. Otherwise, use "(c++)" as the tag
3397+ # and add " 0replaceme", so the new symbol will be accepted.
3398+ line = p.stdout.readline().decode('utf-8')
3399+ outfile.write(line) # Write library name and version
3400+ for line in p.stdout:
3401+ mo = new_regex.match(line.decode('utf-8'))
3402+ if (mo):
3403+ sym = mo.group(1)
3404+ try:
3405+ tag, version = old_syms[sym]
3406+ except KeyError:
3407+ tag = '(c++)'
3408+ version = '0replaceme'
3409+ outfile.write(' {}"{}" {}\n'.format(tag, sym, version))
3410+ else:
3411+ raise Exception('Cannot parse demangled line: ' + line)
3412+
3413+ # Write the diff into /tmp/symbols.diff
3414+ with open('/tmp/symbols.diff', 'w') as outfile:
3415+ subprocess.call(['diff', '-u', OLD_FILE, 'new_symbols'], stdout=outfile)
3416+
3417+if __name__ == '__main__':
3418+ run()

Subscribers

People subscribed via source and target branches