Merge lp:~thomas-voss/location-service/fwd-merge into lp:location-service/trunk

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/location-service/fwd-merge
Merge into: lp:location-service/trunk
Diff against target: 2784 lines (+1908/-192)
48 files modified
CMakeLists.txt (+14/-0)
_clang-format (+56/-0)
astyle-config (+43/-0)
debian/changelog (+91/-0)
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 (+23/-14)
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 (+3/-3)
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:~thomas-voss/location-service/fwd-merge
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+282431@code.launchpad.net

Commit message

[ Alberto Mardegan ]
* Set debian source format to "3.0 (native)"
[ Scott Sweeny ]
* Allow providers to register themselves asynchronously (LP: #1415029)
* Account for changes in trust-store w.r.t. assembling the description
  of a trust prompt.
* Fix settings not being applied correctly.
* Ensure that event connections are cleaned up on destruction. (LP:
  #1480877)
[ Alberto Mardegan ]
* Send last known position on session start
[ CI Train Bot ]
* New rebuild forced.
[ Thomas Voß ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
[ thomas-voss ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
* Adjust default timeout for downloading GPS XTRA data.
[ Alberto Mardegan ]
* Make sure that injected time is given in milliseconds
[ Thomas Voß ]
* Cherry-pick rev. 196 and 199 from lp:location-service. The changes
  got accidentally removed by merging the outstanding documentation
  branch.
* Handle responses of clients to updates asynchronously. Rely on
  dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
  #1462664, #1387643)
[ Thomas Voß ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.
[ thomas-voss ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.

Description of the change

[ Alberto Mardegan ]
* Set debian source format to "3.0 (native)"
[ Scott Sweeny ]
* Allow providers to register themselves asynchronously (LP: #1415029)
* Account for changes in trust-store w.r.t. assembling the description
  of a trust prompt.
* Fix settings not being applied correctly.
* Ensure that event connections are cleaned up on destruction. (LP:
  #1480877)
[ Alberto Mardegan ]
* Send last known position on session start
[ CI Train Bot ]
* New rebuild forced.
[ Thomas Voß ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
[ thomas-voss ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
* Adjust default timeout for downloading GPS XTRA data.
[ Alberto Mardegan ]
* Make sure that injected time is given in milliseconds
[ Thomas Voß ]
* Cherry-pick rev. 196 and 199 from lp:location-service. The changes
  got accidentally removed by merging the outstanding documentation
  branch.
* Handle responses of clients to updates asynchronously. Rely on
  dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
  #1462664, #1387643)
[ Thomas Voß ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.
[ thomas-voss ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

219. By Thomas Voß

[ Alberto Mardegan ]
* Set debian source format to "3.0 (native)"
[ Scott Sweeny ]
* Allow providers to register themselves asynchronously (LP: #1415029)
* Account for changes in trust-store w.r.t. assembling the description
  of a trust prompt.
* Fix settings not being applied correctly.
* Ensure that event connections are cleaned up on destruction. (LP:
  #1480877)
[ Alberto Mardegan ]
* Send last known position on session start
[ CI Train Bot ]
* New rebuild forced.
[ Thomas Voß ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
[ thomas-voss ]
* Factor out service::Runtime from daemon.cpp into its own .h/.cpp
  pair of files. Add test cases around correct operation of
  service::Runtime. added:
  src/location_service/com/ubuntu/location/service/runtime.cpp
  src/location_service/com/ubuntu/location/service/runtime.h
  tests/runtime_test.cpp
* Adjust default timeout for downloading GPS XTRA data.
[ Alberto Mardegan ]
* Make sure that injected time is given in milliseconds
[ Thomas Voß ]
* Cherry-pick rev. 196 and 199 from lp:location-service. The changes
  got accidentally removed by merging the outstanding documentation
  branch.
* Handle responses of clients to updates asynchronously. Rely on
  dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
  #1462664, #1387643)
[ Thomas Voß ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.
[ thomas-voss ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-09-18 23:06:08 +0000
+++ CMakeLists.txt 2016-01-13 12:31:53 +0000
@@ -54,6 +54,20 @@
54 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")54 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
55endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)55endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
5656
57#
58# Code style fixer. We rely on clang-format to adjust the formatting of source code.
59#
60find_program(CLANG_FORMAT_COMMAND NAMES clang-format-3.6 clang-format-3.5)
61if (NOT CLANG_FORMAT_COMMAND)
62 message(WARNING "Cannot find clang-format >= clang-format-3.5: formatcode target will not be available")
63endif()
64
65if (CLANG_FORMAT_COMMAND)
66 file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h)
67 file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES ${CMAKE_SOURCE_DIR}/src/*.h ${CMAKE_SOURCE_DIR}/src/*.cpp)
68 add_custom_target(formatcode ${CLANG_FORMAT_COMMAND} -i ${UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES} ${UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES} SOURCES _clang-format)
69endif()
70
57include_directories(71include_directories(
58 ${Boost_INCLUDE_DIRS}72 ${Boost_INCLUDE_DIRS}
59 ${DBUS_INCLUDE_DIRS}73 ${DBUS_INCLUDE_DIRS}
6074
=== added file '_clang-format'
--- _clang-format 1970-01-01 00:00:00 +0000
+++ _clang-format 2016-01-13 12:31:53 +0000
@@ -0,0 +1,56 @@
1---
2Language: Cpp
3AccessModifierOffset: -4
4ConstructorInitializerIndentWidth: 4
5AlignEscapedNewlinesLeft: false
6AlignTrailingComments: true
7AllowAllParametersOfDeclarationOnNextLine: true
8AllowShortBlocksOnASingleLine: false
9AllowShortIfStatementsOnASingleLine: false
10AllowShortLoopsOnASingleLine: false
11AllowShortFunctionsOnASingleLine: All
12AlwaysBreakTemplateDeclarations: false
13AlwaysBreakBeforeMultilineStrings: false
14BreakBeforeBinaryOperators: false
15BreakBeforeTernaryOperators: true
16BreakConstructorInitializersBeforeComma: false
17BinPackParameters: true
18ColumnLimit: 0
19ConstructorInitializerAllOnOneLineOrOnePerLine: false
20DerivePointerAlignment: false
21ExperimentalAutoDetectBinPacking: false
22IndentCaseLabels: false
23IndentWrappedFunctionNames: false
24IndentFunctionDeclarationAfterType: false
25MaxEmptyLinesToKeep: 1
26KeepEmptyLinesAtTheStartOfBlocks: true
27NamespaceIndentation: None
28ObjCSpaceAfterProperty: false
29ObjCSpaceBeforeProtocolList: true
30PenaltyBreakBeforeFirstCallParameter: 19
31PenaltyBreakComment: 300
32PenaltyBreakString: 1000
33PenaltyBreakFirstLessLess: 120
34PenaltyExcessCharacter: 1000000
35PenaltyReturnTypeOnItsOwnLine: 60
36PointerAlignment: Left
37SpacesBeforeTrailingComments: 1
38Cpp11BracedListStyle: true
39Standard: Cpp11
40IndentWidth: 4
41TabWidth: 8
42UseTab: Never
43BreakBeforeBraces: Allman
44SpacesInParentheses: false
45SpacesInAngles: false
46SpaceInEmptyParentheses: false
47SpacesInCStyleCastParentheses: false
48SpacesInContainerLiterals: true
49SpaceBeforeAssignmentOperators: true
50ContinuationIndentWidth: 4
51CommentPragmas: '^ IWYU pragma:'
52ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
53SpaceBeforeParens: ControlStatements
54DisableFormat: false
55...
56
057
=== added file 'astyle-config'
--- astyle-config 1970-01-01 00:00:00 +0000
+++ astyle-config 2016-01-13 12:31:53 +0000
@@ -0,0 +1,43 @@
1# Options for formatting code with astyle.
2#
3# This helps to make code match the style guide.
4#
5# Use like this:
6#
7# astyle --options=astyle-config mfile.h myfile.cpp
8#
9# Occasionally, astyle does something silly (particularly with lambdas), so it's
10# still necessary to scan the changes for things that are wrong.
11# But, for most files, it does a good job.
12#
13# Please consider using this before checking code in for review. Code reviews shouldn't
14# have to deal with layout issues, they are just a distraction. It's better to be able
15# to focus on semantics in a code review, with style issues out of the way.
16
17--formatted
18--style=allman
19--min-conditional-indent=2
20--indent-switches
21--max-instatement-indent=120
22--pad-header
23--align-pointer=type
24--align-reference=type
25--convert-tabs
26--close-templates
27--max-code-length=120
28
29# --pad-oper
30#
31# Commented out for now. It changes
32#
33# for (int i=0; i<10; ++i)
34# to
35# for (int i = 0; i < 10; ++i)
36#
37# Unfortunately, it also messes with rvalue references:
38#
39# ResourcePtr& operator=(ResourcePtr&& r);
40#
41# becomes:
42#
43# ResourcePtr& operator=(ResourcePtr && r);
044
=== modified file 'debian/changelog'
--- debian/changelog 2015-07-27 18:07:37 +0000
+++ debian/changelog 2016-01-13 12:31:53 +0000
@@ -36,6 +36,97 @@
3636
37 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +000037 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +0000
3838
39location-service (2.1+15.04.20160106-0ubuntu1) vivid; urgency=medium
40
41 [ Alberto Mardegan ]
42 * Set debian source format to "3.0 (native)"
43
44 [ Scott Sweeny ]
45 * Allow providers to register themselves asynchronously (LP: #1415029)
46
47 -- Thomas Voß <ci-train-bot@canonical.com> Wed, 06 Jan 2016 16:15:29 +0000
48
49location-service (2.1+15.04.20151211-0ubuntu1) vivid; urgency=medium
50
51 * Account for changes in trust-store w.r.t. assembling the description
52 of a trust prompt.
53
54 -- Thomas Voß <ci-train-bot@canonical.com> Fri, 11 Dec 2015 08:57:44 +0000
55
56location-service (2.1+15.04.20151209-0ubuntu1) vivid; urgency=medium
57
58 * Fix settings not being applied correctly.
59
60 -- Thomas Voß <ci-train-bot@canonical.com> Wed, 09 Dec 2015 15:22:22 +0000
61
62location-service (2.1+15.04.20151202.1-0ubuntu1) vivid; urgency=medium
63
64 * Ensure that event connections are cleaned up on destruction. (LP:
65 #1480877)
66
67 -- Thomas Voß <ci-train-bot@canonical.com> Wed, 02 Dec 2015 12:12:21 +0000
68
69location-service (2.1+15.04.20151127-0ubuntu1) vivid; urgency=medium
70
71 [ Alberto Mardegan ]
72 * Send last known position on session start
73
74 [ CI Train Bot ]
75 * New rebuild forced.
76
77 [ Thomas Voß ]
78 * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
79 pair of files. Add test cases around correct operation of
80 service::Runtime. added:
81 src/location_service/com/ubuntu/location/service/runtime.cpp
82 src/location_service/com/ubuntu/location/service/runtime.h
83 tests/runtime_test.cpp
84
85 [ thomas-voss ]
86 * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
87 pair of files. Add test cases around correct operation of
88 service::Runtime. added:
89 src/location_service/com/ubuntu/location/service/runtime.cpp
90 src/location_service/com/ubuntu/location/service/runtime.h
91 tests/runtime_test.cpp
92
93 -- Thomas Voß <ci-train-bot@canonical.com> Fri, 27 Nov 2015 13:00:33 +0000
94
95location-service (2.1+15.04.20151113-0ubuntu1) vivid; urgency=medium
96
97 * Adjust default timeout for downloading GPS XTRA data.
98
99 -- Thomas Voß <ci-train-bot@canonical.com> Fri, 13 Nov 2015 10:33:56 +0000
100
101location-service (2.1+15.04.20151109.2-0ubuntu1) vivid; urgency=medium
102
103 [ Alberto Mardegan ]
104 * Make sure that injected time is given in milliseconds
105
106 [ Thomas Voß ]
107 * Cherry-pick rev. 196 and 199 from lp:location-service. The changes
108 got accidentally removed by merging the outstanding documentation
109 branch.
110 * Handle responses of clients to updates asynchronously. Rely on
111 dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
112 #1462664, #1387643)
113
114 -- David Barth <david.barth@canonical.com> Mon, 09 Nov 2015 20:48:48 +0000
115
116location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium
117
118 [ Thomas Voß ]
119 * Add documentation for debugging, hacking and debugging the location
120 service. Pull manual testing instructions over from the wiki. Add
121 tools for formatting the source.
122
123 [ thomas-voss ]
124 * Add documentation for debugging, hacking and debugging the location
125 service. Pull manual testing instructions over from the wiki. Add
126 tools for formatting the source.
127
128 -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000
129
39location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium130location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium
40131
41 [ CI Train Bot ]132 [ CI Train Bot ]
42133
=== modified file 'debian/source/format'
--- debian/source/format 2014-07-30 14:15:06 +0000
+++ debian/source/format 2016-01-13 12:31:53 +0000
@@ -1,1 +1,1 @@
13.0 (quilt)13.0 (native)
22
=== modified file 'doc/Doxyfile.in'
--- doc/Doxyfile.in 2014-05-19 09:55:25 +0000
+++ doc/Doxyfile.in 2016-01-13 12:31:53 +0000
@@ -748,7 +748,7 @@
748# directories that contain image that are included in the documentation (see748# directories that contain image that are included in the documentation (see
749# the \image command).749# the \image command).
750750
751IMAGE_PATH =751IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images
752752
753# The INPUT_FILTER tag can be used to specify a program that doxygen should753# The INPUT_FILTER tag can be used to specify a program that doxygen should
754# invoke to filter for each input file. Doxygen will invoke the filter program754# invoke to filter for each input file. Doxygen will invoke the filter program
@@ -1463,7 +1463,7 @@
1463# generate an XML file that captures the structure of1463# generate an XML file that captures the structure of
1464# the code including all documentation.1464# the code including all documentation.
14651465
1466GENERATE_XML = NO1466GENERATE_XML = YES
14671467
1468# The XML_OUTPUT tag is used to specify where the XML pages will be put.1468# The XML_OUTPUT tag is used to specify where the XML pages will be put.
1469# If a relative path is entered the value of OUTPUT_DIRECTORY will be1469# If a relative path is entered the value of OUTPUT_DIRECTORY will be
14701470
=== added file 'doc/daemon_and_cli.md'
--- doc/daemon_and_cli.md 1970-01-01 00:00:00 +0000
+++ doc/daemon_and_cli.md 2016-01-13 12:31:53 +0000
@@ -0,0 +1,55 @@
1# Service Daemon and CLI
2
3The location service offers a daemon executable and a corresponding
4command-line interface for interacting with it. The daemon does not
5necessarily require root privileges, but might so depending on your
6configuration.
7
8Run the following command to receive an overview of the arguments to
9the daemon:
10
11 ubuntu-location-serviced --help
12
13An example invocation of the daemon, configuring a GPS provider that
14relies on the Android HAL to talk to the chipset, exposing the service
15on the system DBus instance:
16
17 ubuntu-location-serviced --bus system --provider gps::Provider
18
19The cli allows for querying properties of a running service instance, e.g.:
20
21 ubuntu-location-serviced-cli --bus system --get --property is_online
22
23## Configuring an Out-Of-Process Provider
24
25If you want to run a provider out of process, the daemon executable
26allows you to do so by instantiating a so-called remote provider. The
27following invocation of the service tries to connect to the provider
28instance described by the given unique DBus name and path.
29
30 ubuntu-location-serviced \
31 --bus system \
32 --provider remote::Provider \
33 --remote::Provider::bus=system \
34 --remote::Provider::name=com.ubuntu.location.provider.Gps \
35 --remote::Provider::path=/
36
37Please note that the service allows for decorating provider names to
38uniquely identify per provider configuration options and to allow for
39loading more than one provider of a certain kind. The following
40configuration configures two remote providers, one relying on GPS
41(decorated with @gps) and another one relying on network-based
42positioning (decorated with @network):
43
44 ubuntu-location-serviced \
45 --bus system \
46 --provider remote::Provider@gps \
47 --remote::Provider@gps::bus=system \
48 --remote::Provider@gps::name=com.ubuntu.location.provider.Gps \
49 --remote::Provider@gps::path=/ \
50 --provider remote::Provider@network \
51 --remote::Provider@network::bus=system \
52 --remote::Provider@network::name=com.ubuntu.location.provider.Network \
53 --remote::Provider@network::path=/
54
55
056
=== added file 'doc/debugging.md'
--- doc/debugging.md 1970-01-01 00:00:00 +0000
+++ doc/debugging.md 2016-01-13 12:31:53 +0000
@@ -0,0 +1,92 @@
1# Debugging
2
3Location not working? Here's how to debug.
4
5## Layers
6
7Test in OSMTouch (QML app using Qt API) before testing in webapps or
8webbrowser app. Different results? File a bug where it doesn't
9work. Same result of no location? Next step.
10
11## Check that stack works with dummy provider
12
13Edit /etc/init/ubuntu-location-provider.override to start
14location-serviced with just the dummy provider; this should
15work. Doesn't work? File a bug against location-service. Works? Reset
16config to defaults and try the next thing.
17
18## Hardware GPS breaking all of location-service
19
20GPS provider is built-in into location-service and might break all of
21it if it goes south (working on splitting it out); try enabling only
22the HERE provider on the location-serviced command-line and see if
23that works. Works? File a bug against location-service. Doesn't work?
24Move on.
25
26## HERE test
27
28To test whether the low-level HERE stack gets a location, put
29http://people.canonical.com/~lool/espoo-cli on your phone (will be
30included along HERE bits in the future) and run with:
31
32 chmod a+x espoo-cli
33 GLOG_logtostderr=1 GLOG_v=100 LD_LIBRARY_PATH=/custom/vendor/here/location-provider/lib/arm-linux-gnueabihf ./espoo-cli 5
34
35NB: 5 is the number of location updates after which the tool exits;
36updates should come in at approx 15s interval. Output looks like:
37
38 I1101 21:30:01.285964 4403 cli.cpp:117] Requested number of updates is 2
39 I1101 21:30:01.299002 4403 cli.cpp:133] Starting location updates
40 I1101 21:30:01.301888 4403 cli.cpp:141] Starting GLib main loop
41 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
42 I1101 21:30:11.306061 4403 cli.cpp:170] Remaining updates: 1
43 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
44 I1101 21:30:26.738348 4403 cli.cpp:148] Stopping location updates
45
46Low-level HERE stack works but location-serviced with just HERE
47provider doesn't work? File a bug against espoo projet (HERE) and/or
48location-service. Low-level HERE stack doesn't work? Move on
49
50## location-service and espoo-service debug
51
52Collect some debug data by editing /etc/init/ubuntu-espoo-service.conf
53and /etc/init/ubuntu-location-service.override and changing the start
54sequence to add some env vars:
55
56 export GLOG_v=200
57 export GLOG_logtostderr=1
58
59before the exec. Reboot, and start some app. You should have some log
60files under /var/log/upstart/ubuntu-espoo-service.log and
61/var/log/upstart/ubuntu-location-service.log to attach to a bug
62report; e.g. a working espoo log looks like this:
63
64 WARNING: Logging before InitGoogleLogging() is written to STDERR
65 I1105 16:30:10.221474 1620 provider.cpp:568] StartPositionUpdates
66 I1105 16:30:10.224901 1620 provider.cpp:122] Successfully started position updates.
67 I1105 16:30:10.228739 1620 provider.cpp:596] StartVelocityUpdates
68 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)
69
70No position there? check connectivity API works by running:
71
72 cd /tmp
73 wget http://people.ubuntu.com/~lool/connectivity
74 GLOG_v=200 GLOG_logtostderr=1 ./connectivity
75
76you should see something like:
77
78 I1105 16:47:26.431466 11140 cached_radio_cell.cpp:160] (mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
79 I1105 16:47:26.533818 11140 connectivity.cpp:47] Is wifi enabled: true
80 I1105 16:47:26.533963 11140 connectivity.cpp:48] Is wifi hw enabled: true
81 I1105 16:47:26.534010 11140 connectivity.cpp:49] Is wwan enabled: true
82 I1105 16:47:26.534050 11140 connectivity.cpp:50] Is wwan hw enabled: true
83 I1105 16:47:26.534442 11140 connectivity.cpp:122] umts(mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
84 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)
85 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)
86
87Also, please attach output of /usr/share/ofono/scripts/list-modems > list-modems-output.txt
88Please note that the command might take ~1 minute to complete.
89
90TODO: document dbus-monitor / d-feet capturing of client / system traffic with snooping config.
91
92
093
=== added file 'doc/hacking.md'
--- doc/hacking.md 1970-01-01 00:00:00 +0000
+++ doc/hacking.md 2016-01-13 12:31:53 +0000
@@ -0,0 +1,146 @@
1# Hacking
2
3
4## Building the code
5
6By default, the code is built in release mode. To build a debug version, use
7
8 $ mkdir builddebug
9 $ cd builddebug
10 $ cmake -DCMAKE_BUILD_TYPE=debug ..
11 $ make
12
13For a release version, use -DCMAKE_BUILD_TYPE=release
14
15## Running the tests
16
17 $ make
18 $ make test
19
20Note that "make test" alone is dangerous because it does not rebuild
21any tests if either the library or the test files themselves need
22rebuilding. It's not possible to fix this with cmake because cmake cannot
23add build dependencies to built-in targets. To make sure that everything
24is up-to-date, run "make" before running "make test"!
25
26## Coverage
27
28To build with the flags for coverage testing enabled and get coverage:
29
30 $ mkdir buildcoverage
31 $ cd buildcoverage
32 $ cmake -DCMAKE_BUILD_TYPE=coverage
33 $ make
34 $ make test
35 $ make coverage
36
37Unfortunately, it is not possible to get 100% coverage for some files,
38mainly due to gcc's generation of two destructors for dynamic and non-
39dynamic instances. For abstract base classes and for classes that
40prevent stack and static allocation, this causes one of the destructors
41to be reported as uncovered.
42
43There are also issues with some functions in header files that are
44incorrectly reported as uncovered due to inlining, as well as
45the impossibility of covering defensive assert(false) statements,
46such as an assert in the default branch of a switch, where the
47switch is meant to handle all possible cases explicitly.
48
49If you run a binary and get lots of warnings about a "merge mismatch for summaries",
50this is caused by having made changes to the source that add or remove code
51that was previously run, so the new coverage output cannot sensibly be merged
52into the old coverage output. You can get rid of this problem by running
53
54 $ make clean-coverage
55
56This deletes all the .gcda files, allowing the merge to (sometimes) succeed again.
57If this doesn't work either, the only remedy is to do a clean build.
58
59If lcov complains about unrecognized lines involving '=====',
60you can patch geninfo and gcovr as explained here:
61
62https://bugs.launchpad.net/gcovr/+bug/1086695/comments/2
63
64## Code style
65
66We use a format tool that fixes a whole lot of issues
67regarding code style. The formatting changes made by
68the tool are generally sensible (even though they may not be your
69personal preference in all cases). If there is a case where the formatting
70really messes things up, consider re-arranging the code to avoid the problem.
71The convenience of running the entire code base through the pretty-printer
72far outweighs any minor glitches with pretty printing, and it means that
73we get consistent code style for free, rather than endlessly having to
74watch out for formatting issues during code reviews.
75
76As of clang-format-3.7, you can use
77
78 // clang-format off
79 void unformatted_code ;
80 // clang-format on
81
82to suppress formatting for a section of code.
83
84To format specific files:
85
86 ${CMAKE_BINARY_DIR}/tools/formatcode x.cpp x.h
87
88If no arguments are provided, formatcode reads stdin and writes
89stdout, so you can easily pipe code into the tool from within an
90editor. For example, to reformat the entire file in vi (assuming
91${CMAKE_BINARY_DIR}/tools is in your PATH):
92
93 1G!Gformatcode
94
95To re-format all source and header files in the tree:
96
97 $ make formatcode
98
99## Thread and address sanitizer
100
101Set SANITIZER to "thread" or "address" to build with the
102corresponding sanitizer enabled.
103
104## Updating symbols file
105
106To easily spot new/removed/changed symbols in the library, the debian
107package maintains a .symbols file that lists all exported symbols
108present in the library .so. If you add new public symbols to the library,
109it's necessary to refresh the symbols file, otherwise the package will
110fail to build. The easiest way to do that is using bzr-builddeb:
111
112 $ bzr bd -- -us -uc -j8 # Don't sign source package or changes file, 8 compiles in parallel
113 $ # this will exit with an error if symbols file isn't up-to-date
114 $ cd ../build-area/location-service-[version]
115 $ ./obj-[arch]/tools/symbol_diff
116
117This creates a diff of the symbols in /tmp/symbols.diff.
118(The demangled symbols from the debian build are in ./new_symbols.)
119
120Review any changes in /tmp/symbols.diff. If they are OK:
121
122 $ cd -
123 $ patch -p0 < /tmp/symbols.diff
124
125## ABI compliance test
126
127To use this, install abi-compliance-checker package from the archives.
128
129You can use abi-compliance-checker to test whether a particular build
130is ABI compatible with another build. The tool does some source-level
131analysis in addition to checking library symbols, so it catches things
132that are potentially dangerous, but won't be picked up by just looking
133at the symbol table.
134
135Assume you have built devel in src/devel, and you have a later build
136in src/mybranch and want to check that mybranch is still compatible.
137To run the compliance test:
138
139 $ cd src
140 $ abi-compliance-checker -lib libunity-scopes.so -old devel/build/test/abi-compliance/abi.xml -new mybranch/build/test/abi-compliance/abi.xml
141
142The script will take about two minutes to run. Now point your browser at
143
144 src/compat_reports/libunity-scopes.so/[version]_to_[version]/compat_report.html
145
146The report provides a nicely layed-out page with all the details.
0147
=== added directory 'doc/images'
=== added file 'doc/images/LocationServiceHighLevel.png'
1Binary files doc/images/LocationServiceHighLevel.png 1970-01-01 00:00:00 +0000 and doc/images/LocationServiceHighLevel.png 2016-01-13 12:31:53 +0000 differ148Binary files doc/images/LocationServiceHighLevel.png 1970-01-01 00:00:00 +0000 and doc/images/LocationServiceHighLevel.png 2016-01-13 12:31:53 +0000 differ
=== added file 'doc/intro.md'
--- doc/intro.md 1970-01-01 00:00:00 +0000
+++ doc/intro.md 2016-01-13 12:31:53 +0000
@@ -0,0 +1,67 @@
1# Introduction {#mainpage}
2
3Ubuntu's location service is a central hub for multiplexing access to
4positioning subsystems available via hard- and software. It provides a
5client API offering positioning capabilities to applications and other
6system components, abstracting away the details of individual
7positioning solutions.
8
9## Vocabulary
10
11To make the remainder of this documentation as easily understandable
12as possible, we start over with introducing some vocabulary:
13
14- Engine:
15 Responsible for handling input from multiple positioning
16 subsystems and maintaining the state of the overall system. Think
17 about it like the heart of the system.
18
19- Provider:
20 A positioning subsystem that feeds into the positioning
21 engine. Common examples are a GPS provider or a network-based
22 positioning provider.
23
24- Service:
25 The point of entry for applications and services that would
26 like to receive position data.
27
28- Session:
29 In order to receive position information, every application
30 or service has to create a session with the location Service.
31
32- Update: An update is a timestamped entity to a certain type of data.
33
34- [WGS84, http://en.wikipedia.org/wiki/World_Geodetic_System]: The coordinate system that is used throughout the entire location subsystem.
35
36## Architectural Overview
37
38The high-level architecture of the service is shown in the following diagram:
39
40![High-level architectural overview](images/LocationServiceHighLevel.png)
41
42In this diagram, the configuration of the engine refers to:
43
44 * The current state of any satellite-based positioning subsystems. Can either be off or on.
45 * 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.
46 * The overall state of the engine. Can either be off, on or active.
47
48The Service takes this configuration and exposes it to client
49applications. In addition, mainly for debugging purposes, the set of
50currently visible satellites (if any) is maintained and exposed to
51privileged client applications.
52
53## Privacy & Access Control
54
55Location information is highly privacy relevant. For this reason, the
56location service is deeply integrated with AppArmor and Ubuntu's
57overall trust infrastructure. Every incoming session request is
58validated and if in doubt, the user is asked to explicitly grant trust
59to the application requesting access to positioning
60information. Please see [@ref com::ubuntu::location::service::PermissionManager]
61for further details.
62
63In addition, the location service allows for selectively adjusting the
64accuracy and reporting setup of the location Engine to provide further
65fine-grained control over the exposed data to user. Within this setup,
66a user is able to entirely disable all positioning.
67
068
=== added file 'doc/manual_testing.md'
--- doc/manual_testing.md 1970-01-01 00:00:00 +0000
+++ doc/manual_testing.md 2016-01-13 12:31:53 +0000
@@ -0,0 +1,174 @@
1# Manual Testplan
2
3[TOC]
4
5While the automatic test suite of the location service is
6comprehensive and covers large parts of the functionality of the
7service itself, we still provide an additional level of acceptance
8testing covering the entire location stack/experience as a part of
9this document.
10
11## Dependents/Clients
12
13 - qtubuntu-sensors
14 - Qt/QML applications:
15 - Browser
16 - osmTouch
17
18## Test Plan
19
20This test plan is not supposed to be complete; use it to guide your
21manual testing so you don't miss big functional areas that are part of
22the component; also this should be used as guideline to inspire the
23exploratory testing which should be adapted smartly based on the real
24content of a MP.
25
26Please note that if you're testing the GPS provider, the location
27service relies on GPS hardware to obtain a location fix. For that, it
28might be required that you execute the manual steps listed before
29close to a window or ideally outside, with good satellite visibility
30conditions.
31
32__Note: It can take up to 15 minutes for the GPS device to get a lock, due to lack of assisted GPS__
33
34 - Install latest image on phone
35 - Install freshly built MPs that are needed for landing
36
37Depending on the default configuration of location-service on the
38image, you may skip parts of this test plan. E.g. if GPS hardware is
39disabled, skip this part. You can see which providers are enabled by
40looking at the list of providers on the location-serviced command-line
41(`ps fauxw | grep location-service`, then look at the `--provider`
42flags).
43
44### Dummy provider
45
46This tests forces location-service to use only the dummy provider;
47this providers a baseline test for the app to trust-store to
48location-service path.
49
50 - phablet-shell into the phone:
51 - `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`
52 - As phablet, start the trust store again (it stops when location-service is stopped) with: `start ubuntu-location-service-trust-stored`
53 - Ensure that all AP tests for the webbrowser pass as expected
54 - Point the browser to maps.google.com (alternatively: here.com, maps.bing.fr).
55 - Request centering the map on current position and observe if it works correctly (should show the Eiffel tower)
56 - Install osmTouch from the app store
57 - Launch osmTouch and check if it centers on the Eiffel tower.
58 - Install a maps webapp such as HERE or Google Maps webapp from the app store
59 - Launch maps webapp and check if it centers on the Eiffel tower.
60
61### GPS Test Plan
62
63This applies only if GPS provider is enabled.
64
65 - (If applicable: Remember to add the silo you are testing)
66 - `sudo apt-get install ubuntu-location-service-tests`
67 - 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:
68 - `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`
69 - If you '''don't''' want to send off crowdsourced information:
70 - `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`
71
72 - The test will output a lot of diagnostic information to the
73 terminal and will take ~30 minutes. If satellite visibility is
74 limited, it can take even longer. The test will automatically
75 report success or failure.
76
77### Preliminary AGPS Test Plan
78
79**Does not apply to Krillin**
80
81Please note that the Krillin GPS chipset driver and its integration
82within Ubuntu does not support vanilla AGPS (i.e., SUPL) right
83now. For that, this test case is irrelevant for Krillin and is likely
84to fail.
85
86This applied only if GPS provider and some other provider (giving
87_A_ssistance) are enabled.
88
89 - Add the silo.
90 - `sudo apt-get install ubuntu-location-service-tests`
91 - Obtain a (rough) location estimate for your current location on Google maps.
92 - Make sure to replace INSERT_ESTIMATE_HERE with the respective
93 values obtained from Google maps.
94 - If you want to send off crowdsourced information, i.e., information
95 about visible wifis and visible radio cells for the obtained
96 location fixes to Mozilla's location service and our own instance:
97 - `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`
98 - If you '''don't''' want to send off crowdsourced information:
99 - `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`
100
101 - The test will output a lot of diagnostic information to the
102 terminal and will take ~10 minutes or less. The test will
103 automatically report success or failure.
104
105### Espoo / HERE provider
106
107This applies only if the Espoo / HERE remote provider is enabled. This
108provider should be enabled by default and may either work standalone
109as the only provider or as an assistance for the GPS hardware to lock.
110
111 - Add the silo; special exception for lxc-android-config: see https://wiki.ubuntu.com/Touch/Testing/lxc-android-config
112 - If noted, deploy an updated custom tarball:
113 - Download the tarball under /tmp ('''NOT''' under /)
114 - Unpack there: `cd /tmp; sudo tar xvf custom-vendor-here-*.tar.xz`
115 - Remove older bits: `sudo rm -rf /custom/vendor/here/`
116 - Update custom bits: `sudo mv /tmp/system/custom/vendor/here /custom/vendor`
117 - Reboot
118 - After boot, check you have these three processes running on top of location-service:
119 - slpgwd
120 - posclientd
121 - ubuntu-espoo-service
122 - Make sure SIM is unlocked and attached to the network (has some reliable signal) and that WiFi is turned on.
123 - Install OSMTouch app
124 - Run OSMTouch app, hit the position button every other second until you get a blue circle showing your current location;
125
126# Connectivity API
127
128For integration of network-based positioning providers, the location
129service offers a connectivity API that provides access to wifi and
130cell measurements as well as information on the current overall
131connectivity status of the device. Please execute the following
132commands on a newly flashed device with a writable image:
133
134 - `sudo apt-get update && sudo apt-get build-dep location-service && sudo apt-get install libubuntu-location-service-dev ubuntu-location-service-examples`
135 - `mkdir /tmp/build && cd /tmp/build && cmake /usr/share/ubuntu-location-service/examples/standalone/connectivity/ && make`
136 - `GLOG_logtostderr=1 ./connectivity`
137
138Verify that the output looks similar to:
139
140 phablet@ubuntu-phablet:/tmp/build$ ./connectivity
141 Is wifi enabled: true
142 Is wifi hw enabled: true
143 Is wwan enabled: false
144 Is wwan hw enabled: true
145 umts(mcc: 262, mnc: 2, lac: 5313, id: 131948771, asu: 7)
146 (bssid: BC:F2:AF:AF:19:A2, ssid: devolo-bcf2afaf19a2, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2462, strength: 72)
147 (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 24)
148 (bssid: 82:C7:A6:40:8C:4E, ssid: EasyBox-44D054, last seen: 1408955206, mode: Mode::infrastructure, frequency: 2417, strength: 17)
149 (bssid: 00:24:01:B8:32:8D, ssid: gra, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 12)
150 (bssid: C0:25:06:3C:28:22, ssid: FRITZ!Box 6360 Cable, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2412, strength: 17)
151 (bssid: 00:1C:4A:A5:B7:59, ssid: FRITZ!Box Fon WLAN 7170, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2437, strength: 10)
152 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)
153 Last seen changed for wifi (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955257, mode: Mode::infrastructure, frequency: 2412, strength: 24)
154 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)
155
156# Trust Store Integration
157
158Please note that we are assuming a freshly wiped system for testing
159here. If you cannot fulfill that pre-condition, please run `rm -rf
160/home/phablet/.local/share/UbuntuLocationService && sudo shutdown -r` prior to running the
161tests:
162
163## Unconfined
164
165 - Open the browser, go to maps.google.com
166 - Observe the in-browser dialog asking for granting access to location.
167
168## Confined Web-App
169
170 - Open the Nokia Here web app, observe the trust dialog appearing.
171
172## Confined Application
173
174 - Open osmtouch and observe the osmtouch surface sliding up, presenting you with a trust dialog.
0175
=== added file 'doc/tips_n_tricks.md'
--- doc/tips_n_tricks.md 1970-01-01 00:00:00 +0000
+++ doc/tips_n_tricks.md 2016-01-13 12:31:53 +0000
@@ -0,0 +1,21 @@
1# Tips'n'Tricks
2
3## Mark HERE license as accepted from cmdline
4
5 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>'
6
7## Force startup after ofono and NM are started
8
9This is a *workaround* to get connectivity API to collect; mount your
10system read-write and edit
11/etc/init/ubuntu-location-provider-here-slpgwd.conf:
12
13 sudo mount -o remount,rw /
14 sudo vi /etc/init/ubuntu-location-provider-here-slpgwd.conf
15
16change: `start on started dbus and (started ofono or started network-manager)`
17to: `start on started dbus and started ofono and started network-manager`
18
19 sudo mount -o remount,ro /
20 sync
21 sudo reboot
022
=== modified file 'examples/service/service.cpp'
--- examples/service/service.cpp 2014-11-14 11:26:45 +0000
+++ examples/service/service.cpp 2016-01-13 12:31:53 +0000
@@ -99,7 +99,10 @@
99 auto selected_providers = options.value_for_key<std::vector<std::string>>("provider");99 auto selected_providers = options.value_for_key<std::vector<std::string>>("provider");
100100
101 std::map<std::string, cul::ProviderFactory::Configuration> config_lut;101 std::map<std::string, cul::ProviderFactory::Configuration> config_lut;
102 std::set<cul::Provider::Ptr> instantiated_providers;102
103 culs::DefaultConfiguration config;
104 auto settings = std::make_shared<cul::BoostPtreeSettings>(options.value_for_key<std::string>("config-file"));
105 auto engine = config.the_engine(std::set<cul::Provider::Ptr>{}, config.the_provider_selection_policy(), settings);
103106
104 for (const std::string& provider : selected_providers)107 for (const std::string& provider : selected_providers)
105 {108 {
@@ -129,15 +132,15 @@
129132
130 try133 try
131 {134 {
132 auto p = cul::ProviderFactory::instance().create_provider_for_name_with_config(135 auto result = std::async(std::launch::async, [provider, config_lut, engine] {
133 provider, 136 return cul::ProviderFactory::instance().create_provider_for_name_with_config(
134 config_lut[provider]);137 provider,
135138 config_lut.at(provider),
136 if (p)139 [engine](cul::Provider::Ptr provider)
137 instantiated_providers.insert(p);140 {
138 else141 engine->add_provider(provider);
139 throw std::runtime_error("Problem instantiating provider");142 });
140 143 });
141 } catch(const std::runtime_error& e)144 } catch(const std::runtime_error& e)
142 {145 {
143 std::cerr << "Exception instantiating provider: " << e.what() << " ... Aborting now." << std::endl;146 std::cerr << "Exception instantiating provider: " << e.what() << " ... Aborting now." << std::endl;
@@ -163,15 +166,11 @@
163 };166 };
164 outgoing->install_executor(dbus::asio::make_executor(outgoing));167 outgoing->install_executor(dbus::asio::make_executor(outgoing));
165168
166 auto settings = std::make_shared<cul::BoostPtreeSettings>(options.value_for_key<std::string>("config-file"));
167
168 culs::DefaultConfiguration config;
169
170 culs::Implementation::Configuration configuration169 culs::Implementation::Configuration configuration
171 {170 {
172 incoming,171 incoming,
173 outgoing,172 outgoing,
174 config.the_engine(instantiated_providers, config.the_provider_selection_policy(), settings),173 engine,
175 config.the_permission_manager(incoming),174 config.the_permission_manager(incoming),
176 culs::Harvester::Configuration175 culs::Harvester::Configuration
177 {176 {
178177
=== modified file 'include/location_service/com/ubuntu/location/provider_factory.h'
--- include/location_service/com/ubuntu/location/provider_factory.h 2014-10-27 21:58:16 +0000
+++ include/location_service/com/ubuntu/location/provider_factory.h 2016-01-13 12:31:53 +0000
@@ -54,6 +54,9 @@
54 // --provider=remote::Provider@gps --remote::Provider@gps::name="com.ubuntu.android.gps.Provider" --remote::Provider@gps::path="/com/ubuntu/android/gps/Provider"54 // --provider=remote::Provider@gps --remote::Provider@gps::name="com.ubuntu.android.gps.Provider" --remote::Provider@gps::path="/com/ubuntu/android/gps/Provider"
55 Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config);55 Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config);
5656
57 // Async version of above.
58 void create_provider_for_name_with_config(const std::string& name, const Configuration& config, const std::function<void(Provider::Ptr)>& cb);
59
57 void enumerate(const std::function<void(const std::string&, const Factory&)>& enumerator);60 void enumerate(const std::function<void(const std::string&, const Factory&)>& enumerator);
5861
59 private:62 private:
6063
=== modified file 'po/ubuntu-location-service.pot'
--- po/ubuntu-location-service.pot 2014-09-19 09:06:30 +0000
+++ po/ubuntu-location-service.pot 2016-01-13 12:31:53 +0000
@@ -1,13 +1,14 @@
1# Copyright (C) 2014 Canonical Ltd.1# SOME DESCRIPTIVE TITLE.
2# This file is distributed under the same license as the ubuntu-location-service package.2# Copyright (C) YEAR Canonical Ltd.
3# Thomas Voß <thomas.voss@canonical.com>, 2014.3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4#5#
5#, fuzzy6#, fuzzy
6msgid ""7msgid ""
7msgstr ""8msgstr ""
8"Project-Id-Version: ubuntu-location-service\n"9"Project-Id-Version: ubuntu-location-service\n"
9"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2014-09-19 01:04+0200\n"11"POT-Creation-Date: 2015-11-27 14:07+0100\n"
11"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,11 +17,6 @@
16"Content-Type: text/plain; charset=CHARSET\n"17"Content-Type: text/plain; charset=CHARSET\n"
17"Content-Transfer-Encoding: 8bit\n"18"Content-Transfer-Encoding: 8bit\n"
1819
19#: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:17020#: /home/tvoss/ubuntu/scratch/fix-prompt-string/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:149
20msgid "An unconfined application wants to access your current location."21msgid "wants to access your current location."
21msgstr ""
22
23#: /tmp/i18n/src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp:173
24#, boost-format
25msgid "%1% wants to access your current location."
26msgstr ""22msgstr ""
2723
=== modified file 'src/location_service/com/ubuntu/location/CMakeLists.txt'
--- src/location_service/com/ubuntu/location/CMakeLists.txt 2015-04-23 14:48:44 +0000
+++ src/location_service/com/ubuntu/location/CMakeLists.txt 2016-01-13 12:31:53 +0000
@@ -38,6 +38,7 @@
38 service/harvester.cpp38 service/harvester.cpp
39 service/demultiplexing_reporter.h39 service/demultiplexing_reporter.h
40 service/demultiplexing_reporter.cpp40 service/demultiplexing_reporter.cpp
41 service/runtime.cpp
41 service/runtime_tests.h42 service/runtime_tests.h
42 service/runtime_tests.cpp43 service/runtime_tests.cpp
43 service/trust_store_permission_manager.cpp44 service/trust_store_permission_manager.cpp
4445
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp'
--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-05-28 10:57:24 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2016-01-13 12:31:53 +0000
@@ -123,7 +123,14 @@
123 const org::freedesktop::NetworkManager::Device& device,123 const org::freedesktop::NetworkManager::Device& device,
124 const org::freedesktop::NetworkManager::AccessPoint& ap)124 const org::freedesktop::NetworkManager::AccessPoint& ap)
125 : device_(device),125 : device_(device),
126 access_point_(ap)126 access_point_(ap),
127 connections
128 {
129 access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
130 {
131 on_access_point_properties_changed(dict);
132 })
133 }
127{134{
128 last_seen_ = translate_time_stamp(access_point_.last_seen->get());135 last_seen_ = translate_time_stamp(access_point_.last_seen->get());
129136
@@ -138,12 +145,11 @@
138 {145 {
139 static_cast<int>(access_point_.strength->get())146 static_cast<int>(access_point_.strength->get())
140 };147 };
148}
141149
142 // Wire up all the connections150detail::CachedWirelessNetwork::~CachedWirelessNetwork()
143 access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)151{
144 {152 access_point_.properties_changed->disconnect(connections.ap_properties_changed);
145 on_access_point_properties_changed(dict);
146 });
147}153}
148154
149void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)155void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)
150156
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h'
--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2014-08-14 20:25:22 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2016-01-13 12:31:53 +0000
@@ -41,6 +41,8 @@
41 const org::freedesktop::NetworkManager::Device& device,41 const org::freedesktop::NetworkManager::Device& device,
42 const org::freedesktop::NetworkManager::AccessPoint& ap);42 const org::freedesktop::NetworkManager::AccessPoint& ap);
4343
44 ~CachedWirelessNetwork();
45
44 // Timestamp when the network became visible.46 // Timestamp when the network became visible.
45 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;47 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;
4648
@@ -67,6 +69,16 @@
67 // The actual access point stub.69 // The actual access point stub.
68 org::freedesktop::NetworkManager::AccessPoint access_point_;70 org::freedesktop::NetworkManager::AccessPoint access_point_;
6971
72 // Encapsulates all event connections that have to be cut on destruction.
73 struct
74 {
75 core::dbus::Signal
76 <
77 org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged,
78 org::freedesktop::NetworkManager::AccessPoint::PropertiesChanged::ArgumentType
79 >::SubscriptionToken ap_properties_changed;
80 } connections;
81
70 core::Property<std::chrono::system_clock::time_point> last_seen_;82 core::Property<std::chrono::system_clock::time_point> last_seen_;
71 core::Property<std::string> bssid_;83 core::Property<std::string> bssid_;
72 core::Property<std::string> ssid_;84 core::Property<std::string> ssid_;
7385
=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp'
--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-05-27 18:40:37 +0000
+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2016-01-13 12:31:53 +0000
@@ -595,7 +595,7 @@
595595
596 xdg::NetworkManager::AccessPoint ap596 xdg::NetworkManager::AccessPoint ap
597 {597 {
598 network_manager->service->add_object_for_path(ap_path)598 network_manager->service->object_for_path(ap_path)
599 };599 };
600600
601 auto wifi = std::make_shared<detail::CachedWirelessNetwork>(itd->second, ap);601 auto wifi = std::make_shared<detail::CachedWirelessNetwork>(itd->second, ap);
602602
=== modified file 'src/location_service/com/ubuntu/location/engine.cpp'
--- src/location_service/com/ubuntu/location/engine.cpp 2015-04-23 14:48:44 +0000
+++ src/location_service/com/ubuntu/location/engine.cpp 2016-01-13 12:31:53 +0000
@@ -169,19 +169,28 @@
169169
170 // We wire up changes in the engine's configuration to the respective slots170 // We wire up changes in the engine's configuration to the respective slots
171 // of the provider.171 // of the provider.
172 auto cp = updates.reference_location.changed().connect([provider](const cul::Update<cul::Position>& pos)172 auto cp = updates.last_known_location.changed().connect([provider](const cul::Optional<cul::Update<cul::Position>>& pos)
173 {173 {
174 provider->on_reference_location_updated(pos);174 if (pos)
175 });175 {
176176 provider->on_reference_location_updated(pos.get());
177 auto cv = updates.reference_velocity.changed().connect([provider](const cul::Update<cul::Velocity>& velocity)177 }
178 {178 });
179 provider->on_reference_velocity_updated(velocity);179
180 });180 auto cv = updates.last_known_velocity.changed().connect([provider](const cul::Optional<cul::Update<cul::Velocity>>& velocity)
181181 {
182 auto ch = updates.reference_heading.changed().connect([provider](const cul::Update<cul::Heading>& heading)182 if (velocity)
183 {183 {
184 provider->on_reference_heading_updated(heading);184 provider->on_reference_velocity_updated(velocity.get());
185 }
186 });
187
188 auto ch = updates.last_known_heading.changed().connect([provider](const cul::Optional<cul::Update<cul::Heading>>& heading)
189 {
190 if (heading)
191 {
192 provider->on_reference_heading_updated(heading.get());
193 }
185 });194 });
186195
187 auto cr = configuration.wifi_and_cell_id_reporting_state.changed().connect([provider](cul::WifiAndCellIdReportingState state)196 auto cr = configuration.wifi_and_cell_id_reporting_state.changed().connect([provider](cul::WifiAndCellIdReportingState state)
@@ -207,7 +216,7 @@
207 // We should come up with a better heuristic here.216 // We should come up with a better heuristic here.
208 auto cpr = provider->updates().position.connect([this](const cul::Update<cul::Position>& src)217 auto cpr = provider->updates().position.connect([this](const cul::Update<cul::Position>& src)
209 {218 {
210 updates.reference_location = update_policy->verify_update(src);219 updates.last_known_location = update_policy->verify_update(src);
211 });220 });
212221
213 std::lock_guard<std::mutex> lg(guard);222 std::lock_guard<std::mutex> lg(guard);
214223
=== modified file 'src/location_service/com/ubuntu/location/engine.h'
--- src/location_service/com/ubuntu/location/engine.h 2015-04-23 14:48:44 +0000
+++ src/location_service/com/ubuntu/location/engine.h 2016-01-13 12:31:53 +0000
@@ -127,11 +127,11 @@
127 struct Updates127 struct Updates
128 {128 {
129 /** The current best known reference location */129 /** The current best known reference location */
130 core::Property<Update<Position>> reference_location{};130 core::Property<Optional<Update<Position>>> last_known_location{};
131 /** The current best known velocity estimate. */131 /** The current best known velocity estimate. */
132 core::Property<Update<Velocity>> reference_velocity{};132 core::Property<Optional<Update<Velocity>>> last_known_velocity{};
133 /** The current best known heading estimate. */133 /** The current best known heading estimate. */
134 core::Property<Update<Heading>> reference_heading{};134 core::Property<Optional<Update<Heading>>> last_known_heading{};
135 /** The current set of visible SpaceVehicles. */135 /** The current set of visible SpaceVehicles. */
136 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>> visible_space_vehicles{};136 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>> visible_space_vehicles{};
137 };137 };
138138
=== modified file 'src/location_service/com/ubuntu/location/provider_factory.cpp'
--- src/location_service/com/ubuntu/location/provider_factory.cpp 2014-10-27 21:58:16 +0000
+++ src/location_service/com/ubuntu/location/provider_factory.cpp 2016-01-13 12:31:53 +0000
@@ -52,6 +52,20 @@
52 return cul::Provider::Ptr{factory_store.at(undecorated_name)(config)};52 return cul::Provider::Ptr{factory_store.at(undecorated_name)(config)};
53}53}
5454
55void cul::ProviderFactory::create_provider_for_name_with_config(
56 const std::string& name,
57 const cul::ProviderFactory::Configuration& config,
58 const std::function<void(Provider::Ptr)>& cb)
59{
60 auto undecorated_name = name.substr(0, name.find("@"));
61
62 std::lock_guard<std::mutex> lg(guard);
63 if (factory_store.count(undecorated_name) == 0)
64 return;
65
66 cb(cul::Provider::Ptr{factory_store.at(undecorated_name)(config)});
67}
68
55void cul::ProviderFactory::enumerate(69void cul::ProviderFactory::enumerate(
56 const std::function<void(const std::string&, const cul::ProviderFactory::Factory&)>& enumerator)70 const std::function<void(const std::string&, const cul::ProviderFactory::Factory&)>& enumerator)
57{71{
5872
=== modified file 'src/location_service/com/ubuntu/location/providers/config.cpp'
--- src/location_service/com/ubuntu/location/providers/config.cpp 2014-09-15 08:58:50 +0000
+++ src/location_service/com/ubuntu/location/providers/config.cpp 2016-01-13 12:31:53 +0000
@@ -19,6 +19,7 @@
19#include <com/ubuntu/location/provider_factory.h>19#include <com/ubuntu/location/provider_factory.h>
2020
21#include "dummy/provider.h"21#include "dummy/provider.h"
22#include "dummy/delayed_provider.h"
2223
23#include <map>24#include <map>
2425
@@ -41,6 +42,12 @@
41 com::ubuntu::location::providers::dummy::Provider::create_instance42 com::ubuntu::location::providers::dummy::Provider::create_instance
42};43};
4344
45static FactoryInjector dummy_delayed_injector
46{
47 "dummy::DelayedProvider",
48 com::ubuntu::location::providers::dummy::DelayedProvider::create_instance
49};
50
44#include <com/ubuntu/location/providers/remote/provider.h>51#include <com/ubuntu/location/providers/remote/provider.h>
45static FactoryInjector remote_injector52static FactoryInjector remote_injector
46{53{
4754
=== modified file 'src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt'
--- src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt 2014-02-07 17:16:49 +0000
+++ src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txt 2016-01-13 12:31:53 +0000
@@ -2,7 +2,9 @@
2 dummy2 dummy
3 3
4 provider.h4 provider.h
5 provider.cpp)5 provider.cpp
6 delayed_provider.h
7 delayed_provider.cpp)
68
7set(9set(
8 ENABLED_PROVIDER_TARGETS10 ENABLED_PROVIDER_TARGETS
911
=== added file 'src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp'
--- src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp 2016-01-13 12:31:53 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Scott Sweeny <scott.sweeny@canonical.com>
17 */
18
19#include <com/ubuntu/location/logging.h>
20
21#include <chrono>
22#include <thread>
23
24#include "delayed_provider.h"
25
26namespace location = com::ubuntu::location;
27namespace dummy = com::ubuntu::location::providers::dummy;
28
29std::string dummy::DelayedProvider::class_name()
30{
31 return "dummy::DelayedProvider";
32}
33
34location::Provider::Ptr dummy::DelayedProvider::create_instance(const ProviderFactory::Configuration& config)
35{
36 int delay = config.get(dummy::DelayConfiguration::Keys::delay, 0);
37 VLOG(1) << __PRETTY_FUNCTION__ << ": delay for " << delay << "ms";
38
39 std::this_thread::sleep_for(std::chrono::milliseconds{delay});
40
41 return dummy::Provider::create_instance(config);
42}
043
=== added file 'src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h'
--- src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.h 2016-01-13 12:31:53 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Scott Sweeny <scott.sweeny@canonical.com>
17 */
18
19#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_DELAYED_PROVIDER_H_
20#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_DELAYED_PROVIDER_H_
21
22#include "provider.h"
23
24namespace com
25{
26namespace ubuntu
27{
28namespace location
29{
30namespace providers
31{
32namespace dummy
33{
34 struct DelayConfiguration
35 {
36 struct Keys
37 {
38 static constexpr const char* delay
39 {
40 "DelayInMs"
41 };
42 };
43 };
44
45class DelayedProvider : public Provider
46{
47 public:
48 // For integration with the Provider factory
49 static std::string class_name();
50 // Waits for "DelayInMs" from the provided property bundle then
51 // instantiates a new provider instance, populating the configuration object
52 // from the provided property bundle.
53 static DelayedProvider::Ptr create_instance(const ProviderFactory::Configuration&);
54 // Creates a new provider instance from the given configuration.
55 DelayedProvider(const Configuration config = Configuration{});
56};
57}
58}
59}
60}
61}
62#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_DELAYED_PROVIDER_H_
063
=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp'
--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2014-10-27 21:58:16 +0000
+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2016-01-13 12:31:53 +0000
@@ -66,8 +66,6 @@
66 if (config.count("XTRA_SERVER_3") > 0)66 if (config.count("XTRA_SERVER_3") > 0)
67 result.xtra_hosts.push_back(config.get<std::string>("XTRA_SERVER_3"));67 result.xtra_hosts.push_back(config.get<std::string>("XTRA_SERVER_3"));
6868
69 result.timeout = std::chrono::milliseconds{1500};
70
71 return result;69 return result;
72}70}
7371
@@ -333,14 +331,14 @@
333 } else331 } else
334 {332 {
335 auto now = location::Clock::now().time_since_epoch();333 auto now = location::Clock::now().time_since_epoch();
336 auto thiz = static_cast<android::HardwareAbstractionLayer*>(context);334 auto ms_since_epoch = std::chrono::duration_cast<std::chrono::milliseconds>(now);
337335
338 static const int zero_uncertainty = 0;336 static const int zero_uncertainty = 0;
339337
340 u_hardware_gps_inject_time(338 u_hardware_gps_inject_time(
341 thiz->impl.gps_handle,339 thiz->impl.gps_handle,
342 now.count(),340 ms_since_epoch.count(),
343 now.count(),341 ms_since_epoch.count(),
344 zero_uncertainty);342 zero_uncertainty);
345 }343 }
346}344}
347345
=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h'
--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2015-04-22 13:30:04 +0000
+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2016-01-13 12:31:53 +0000
@@ -49,7 +49,7 @@
49 /** @brief Timeout on gps xtra download operations. */49 /** @brief Timeout on gps xtra download operations. */
50 std::chrono::milliseconds timeout50 std::chrono::milliseconds timeout
51 {51 {
52 500052 30000
53 };53 };
5454
55 /** Set of hosts serving GPS xtra data. */55 /** Set of hosts serving GPS xtra data. */
5656
=== modified file 'src/location_service/com/ubuntu/location/providers/remote/provider.cpp'
--- src/location_service/com/ubuntu/location/providers/remote/provider.cpp 2015-04-14 18:54:00 +0000
+++ src/location_service/com/ubuntu/location/providers/remote/provider.cpp 2016-01-13 12:31:53 +0000
@@ -23,6 +23,7 @@
23#include <com/ubuntu/location/logging.h>23#include <com/ubuntu/location/logging.h>
2424
25#include <core/dbus/object.h>25#include <core/dbus/object.h>
26#include <core/dbus/service_watcher.h>
26#include <core/dbus/signal.h>27#include <core/dbus/signal.h>
27#include <core/dbus/asio/executor.h>28#include <core/dbus/asio/executor.h>
2829
@@ -191,6 +192,28 @@
191 auto service = dbus::Service::use_service(bus, name);192 auto service = dbus::Service::use_service(bus, name);
192 auto object = service->object_for_path(path);193 auto object = service->object_for_path(path);
193194
195 // Check if the service has come up
196 if (!bus->has_owner_for_name(name)) {
197 // If it hasn't wait for it to come up
198 bool valid = false;
199 std::mutex guard;
200 std::condition_variable cv;
201 dbus::DBus daemon(bus);
202 dbus::ServiceWatcher::Ptr service_watcher(
203 daemon.make_service_watcher(name, dbus::DBus::WatchMode::registration));
204
205 service_watcher->service_registered().connect([&valid, &guard, &cv]()
206 {
207 std::unique_lock<std::mutex> ul(guard);
208 valid = true;
209 cv.notify_all();
210 });
211
212 std::unique_lock<std::mutex> ul(guard);
213 if (not cv.wait_for(ul, std::chrono::seconds{30}, [&valid]() { return valid; }))
214 throw std::runtime_error("Remote service failed to start");
215 }
216
194 return create_instance_with_config(remote::stub::Configuration{object});217 return create_instance_with_config(remote::stub::Configuration{object});
195}218}
196219
197220
=== modified file 'src/location_service/com/ubuntu/location/service/daemon.cpp'
--- src/location_service/com/ubuntu/location/service/daemon.cpp 2015-04-16 10:03:29 +0000
+++ src/location_service/com/ubuntu/location/service/daemon.cpp 2016-01-13 12:31:53 +0000
@@ -20,6 +20,9 @@
20#include <com/ubuntu/location/boost_ptree_settings.h>20#include <com/ubuntu/location/boost_ptree_settings.h>
21#include <com/ubuntu/location/provider_factory.h>21#include <com/ubuntu/location/provider_factory.h>
2222
23#include <com/ubuntu/location/logging.h>
24#include <com/ubuntu/location/connectivity/dummy_connectivity_manager.h>
25
23#include <com/ubuntu/location/service/default_configuration.h>26#include <com/ubuntu/location/service/default_configuration.h>
24#include <com/ubuntu/location/service/demultiplexing_reporter.h>27#include <com/ubuntu/location/service/demultiplexing_reporter.h>
25#include <com/ubuntu/location/service/ichnaea_reporter.h>28#include <com/ubuntu/location/service/ichnaea_reporter.h>
@@ -30,6 +33,7 @@
3033
31#include "program_options.h"34#include "program_options.h"
32#include "daemon.h"35#include "daemon.h"
36#include "runtime.h"
3337
34#include <core/dbus/announcer.h>38#include <core/dbus/announcer.h>
35#include <core/dbus/resolver.h>39#include <core/dbus/resolver.h>
@@ -37,6 +41,8 @@
3741
38#include <core/posix/signal.h>42#include <core/posix/signal.h>
3943
44#include <boost/asio.hpp>
45
40#include <system_error>46#include <system_error>
41#include <thread>47#include <thread>
4248
@@ -175,116 +181,55 @@
175 trap->stop();181 trap->stop();
176 });182 });
177183
178 const location::Configuration empty_provider_configuration;184 auto runtime = location::service::Runtime::create(4);
179185
180 std::set<location::Provider::Ptr> instantiated_providers;186 location::service::DefaultConfiguration dc;
181187 auto engine = dc.the_engine(std::set<location::Provider::Ptr>{}, dc.the_provider_selection_policy(), config.settings);
182 for (const std::string& provider : config.providers)188 for (const std::string& provider : config.providers)
183 {189 {
184 std::cout << "Instantiating and configuring: " << provider << std::endl;190 std::cout << "Instantiating and configuring: " << provider << std::endl;
185191
186 try192 try
187 {193 {
188 auto p = location::ProviderFactory::instance().create_provider_for_name_with_config(194 auto result = std::async(std::launch::async, [provider, config, engine] {
189 provider,195 return location::ProviderFactory::instance().create_provider_for_name_with_config(
190 config.provider_options.count(provider) > 0 ?196 provider,
191 config.provider_options.at(provider) : empty_provider_configuration);197 config.provider_options.count(provider) > 0 ?
192198 config.provider_options.at(provider) : location::Configuration {},
193 if (p)199 [engine](Provider::Ptr provider)
194 instantiated_providers.insert(p);200 {
195 else201 engine->add_provider(provider);
196 throw std::runtime_error("Problem instantiating provider");202 }
197203 );
204 });
198 } catch(const std::runtime_error& e)205 } catch(const std::runtime_error& e)
199 {206 {
200 std::cerr << "Issue instantiating provider: " << e.what() << std::endl;207 std::cerr << "Issue instantiating provider: " << e.what() << std::endl;
201 }208 }
202 }209 }
203210
204 config.incoming->install_executor(dbus::asio::make_executor(config.incoming));211 config.incoming->install_executor(dbus::asio::make_executor(config.incoming, runtime->service()));
205 config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing));212 config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing, runtime->service()));
206213
207 location::service::DefaultConfiguration dc;214 runtime->start();
208215
209 location::service::Implementation::Configuration configuration216 location::service::Implementation::Configuration configuration
210 {217 {
211 config.incoming,218 config.incoming,
212 config.outgoing,219 config.outgoing,
213 dc.the_engine(instantiated_providers, dc.the_provider_selection_policy(), config.settings),220 engine,
214 dc.the_permission_manager(config.outgoing),221 dc.the_permission_manager(config.outgoing),
215 location::service::Harvester::Configuration222 location::service::Harvester::Configuration
216 {223 {
217 location::connectivity::platform_default_manager(),224 std::make_shared<dummy::ConnectivityManager>(),
218 // We submit location/wifi/cell measurements to both225 std::make_shared<NullReporter>()
219 // Mozilla's location service and to Ubuntu's own instance.
220 std::make_shared<service::DemultiplexingReporter>(
221 std::initializer_list<service::Harvester::Reporter::Ptr>
222 {
223 std::make_shared<service::ichnaea::Reporter>(
224 service::ichnaea::Reporter::Configuration
225 {
226 "https://location.services.mozilla.com",
227 "UbuntuLocationService",
228 "UbuntuLocationService"
229 }
230 ),
231 std::make_shared<service::ichnaea::Reporter>(
232 service::ichnaea::Reporter::Configuration
233 {
234 "https://162.213.35.107",
235 "UbuntuLocationService",
236 "UbuntuLocationService"
237 }
238 )
239 })
240 }226 }
241 };227 };
242228
243 auto location_service = std::make_shared<location::service::Implementation>(configuration);229 auto location_service = std::make_shared<location::service::Implementation>(configuration);
244 // We need to ensure that any exception raised by the executor does not crash the app
245 // and also gets logged.
246 auto execute = [] (std::shared_ptr<core::dbus::Bus> bus) {
247 while(true)
248 {
249 try
250 {
251 VLOG(10) << "Starting a bus executor";
252 bus->run();
253 break; // run() exited normally
254 }
255 catch (const std::exception& e)
256 {
257 LOG(WARNING) << e.what();
258 }
259 catch (...)
260 {
261 LOG(WARNING) << "Unexpected exception was raised by the bus executor";
262 }
263 }
264 };
265
266 std::thread t1{execute, config.incoming};
267 std::thread t2{execute, config.incoming};
268 std::thread t3{execute, config.incoming};
269 std::thread t4{execute, config.outgoing};
270230
271 trap->run();231 trap->run();
272232
273 config.incoming->stop();
274 config.outgoing->stop();
275
276 if (t1.joinable())
277 t1.join();
278
279 if (t2.joinable())
280 t2.join();
281
282 if (t3.joinable())
283 t3.join();
284
285 if (t4.joinable())
286 t4.join();
287
288 return EXIT_SUCCESS;233 return EXIT_SUCCESS;
289}234}
290235
291236
=== modified file 'src/location_service/com/ubuntu/location/service/implementation.cpp'
--- src/location_service/com/ubuntu/location/service/implementation.cpp 2014-08-13 13:08:22 +0000
+++ src/location_service/com/ubuntu/location/service/implementation.cpp 2016-01-13 12:31:53 +0000
@@ -113,10 +113,13 @@
113 {113 {
114 visible_space_vehicles() = svs;114 visible_space_vehicles() = svs;
115 }),115 }),
116 configuration.engine->updates.reference_location.changed().connect(116 configuration.engine->updates.last_known_location.changed().connect(
117 [this](const cul::Update<cul::Position>& update)117 [this](const cul::Optional<cul::Update<cul::Position>>& update)
118 {118 {
119 harvester.report_position_update(update);119 if (update)
120 {
121 harvester.report_position_update(update.get());
122 }
120 })123 })
121 }124 }
122{125{
@@ -149,5 +152,23 @@
149 new ProxyProvider{provider_selection}152 new ProxyProvider{provider_selection}
150 };153 };
151154
152 return session::Interface::Ptr{new culs::session::Implementation(proxy_provider)};155 session::Interface::Ptr session_iface{new session::Implementation(proxy_provider)};
156 std::weak_ptr<session::Interface> session_weak{session_iface};
157 session_iface->updates().position_status.changed().connect([this, session_weak](const session::Interface::Updates::Status& status)
158 {
159 cul::Optional<cul::Update<cul::Position>> last_known_position = configuration.engine->updates.last_known_location.get();
160 bool has_last_known_position = last_known_position ? true : false;
161 bool is_session_enabled = status == culs::session::Interface::Updates::Status::enabled;
162 bool is_session_on_or_active = configuration.engine->configuration.engine_state != Engine::Status::off;
163
164 if (has_last_known_position && is_session_enabled && is_session_on_or_active)
165 {
166 // Immediately send the last known position to the client
167 if (auto session_iface = session_weak.lock())
168 {
169 session_iface->updates().position = last_known_position.get();
170 }
171 }
172 });
173 return session_iface;
153}174}
154175
=== modified file 'src/location_service/com/ubuntu/location/service/provider_daemon.cpp'
--- src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2014-10-27 21:58:16 +0000
+++ src/location_service/com/ubuntu/location/service/provider_daemon.cpp 2016-01-13 12:31:53 +0000
@@ -25,6 +25,7 @@
2525
26#include <com/ubuntu/location/service/configuration.h>26#include <com/ubuntu/location/service/configuration.h>
27#include <com/ubuntu/location/service/program_options.h>27#include <com/ubuntu/location/service/program_options.h>
28#include <com/ubuntu/location/service/runtime.h>
2829
29#include <core/dbus/asio/executor.h>30#include <core/dbus/asio/executor.h>
3031
@@ -65,7 +66,6 @@
65 location::service::ProviderDaemon::Configuration result;66 location::service::ProviderDaemon::Configuration result;
6667
67 result.connection = factory(mutable_daemon_options().bus());68 result.connection = factory(mutable_daemon_options().bus());
68 result.connection->install_executor(core::dbus::asio::make_executor(result.connection));
6969
70 auto service = core::dbus::Service::add_service(70 auto service = core::dbus::Service::add_service(
71 result.connection,71 result.connection,
@@ -108,7 +108,15 @@
108 return result;108 return result;
109}109}
110110
111int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& configuration)111namespace
112{
113std::shared_ptr<location::service::Runtime> runtime()
114{
115 static const auto inst = location::service::Runtime::create(2);
116 return inst;
117}
118}
119int location::service::ProviderDaemon::main(const location::service::ProviderDaemon::Configuration& config)
112{120{
113 auto trap = core::posix::trap_signals_for_all_subsequent_threads(121 auto trap = core::posix::trap_signals_for_all_subsequent_threads(
114 {122 {
@@ -121,27 +129,20 @@
121 trap->stop();129 trap->stop();
122 });130 });
123131
124 std::thread worker132 config.connection->install_executor(core::dbus::asio::make_executor(config.connection, runtime()->service()));
125 {
126 [configuration]()
127 {
128 configuration.connection->run();
129 }
130 };
131133
132 auto skeleton = location::providers::remote::skeleton::create_with_configuration(location::providers::remote::skeleton::Configuration134 auto skeleton = location::providers::remote::skeleton::create_with_configuration(location::providers::remote::skeleton::Configuration
133 {135 {
134 configuration.object,136 config.object,
135 configuration.connection,137 config.connection,
136 configuration.provider138 config.provider
137 });139 });
138140
141 runtime()->start();
142
139 trap->run();143 trap->run();
140144
141 configuration.connection->stop();145 config.connection->stop();
142
143 if (worker.joinable())
144 worker.join();
145146
146 return EXIT_SUCCESS;147 return EXIT_SUCCESS;
147}148}
148149
=== added file 'src/location_service/com/ubuntu/location/service/runtime.cpp'
--- src/location_service/com/ubuntu/location/service/runtime.cpp 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/service/runtime.cpp 2016-01-13 12:31:53 +0000
@@ -0,0 +1,109 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTIlocationAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#include <com/ubuntu/location/service/runtime.h>
19
20#include <com/ubuntu/location/logging.h>
21
22namespace culs = com::ubuntu::location::service;
23
24namespace
25{
26// exception_safe_run runs service, catching all exceptions and
27// restarting operation until an explicit shutdown has been requested.
28//
29// TODO(tvoss): Catching all exceptions is risky as they might signal unrecoverable
30// errors. We should enable calling code to decide whether an exception should be considered
31// fatal or not.
32void exception_safe_run(boost::asio::io_service& service)
33{
34 while (true)
35 {
36 try
37 {
38 service.run();
39 // a clean return from run only happens in case of
40 // stop() being called (we are keeping the service alive with
41 // a service::work instance).
42 break;
43 }
44 catch (const std::exception& e)
45 {
46 LOG(WARNING) << e.what();
47 }
48 catch (...)
49 {
50 LOG(WARNING) << "Unknown exception caught while executing boost::asio::io_service";
51 }
52 }
53}
54}
55
56std::shared_ptr<culs::Runtime> culs::Runtime::create(std::uint32_t pool_size)
57{
58 return std::shared_ptr<culs::Runtime>(new culs::Runtime(pool_size));
59}
60
61culs::Runtime::Runtime(std::uint32_t pool_size)
62 : pool_size_{pool_size},
63 service_{pool_size_},
64 strand_{service_},
65 keep_alive_{service_}
66{
67}
68
69culs::Runtime::~Runtime()
70{
71 try
72 {
73 stop();
74 } catch(...)
75 {
76 // Dropping all exceptions to satisfy the nothrow guarantee.
77 }
78}
79
80void culs::Runtime::start()
81{
82 for (unsigned int i = 0; i < pool_size_; i++)
83 workers_.push_back(std::thread{exception_safe_run, std::ref(service_)});
84}
85
86void culs::Runtime::stop()
87{
88 service_.stop();
89
90 for (auto& worker : workers_)
91 if (worker.joinable())
92 worker.join();
93}
94
95std::function<void(std::function<void()>)> culs::Runtime::to_dispatcher_functional()
96{
97 // We have to make sure that we stay alive for as long as
98 // calling code requires the dispatcher to work.
99 auto sp = shared_from_this();
100 return [sp](std::function<void()> task)
101 {
102 sp->strand_.post(task);
103 };
104}
105
106boost::asio::io_service& culs::Runtime::service()
107{
108 return service_;
109}
0110
=== added file 'src/location_service/com/ubuntu/location/service/runtime.h'
--- src/location_service/com/ubuntu/location/service/runtime.h 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/service/runtime.h 2016-01-13 12:31:53 +0000
@@ -0,0 +1,90 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTIlocationAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
19#define COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
20
21#include <boost/asio.hpp>
22
23#include <functional>
24#include <memory>
25#include <thread>
26#include <vector>
27
28#include <cstdint>
29
30namespace com
31{
32namespace ubuntu
33{
34namespace location
35{
36namespace service
37{
38// We bundle our "global" runtime dependencies here, specifically
39// a dispatcher to decouple multiple in-process providers from one
40// another , forcing execution to a well known set of threads.
41class Runtime : public std::enable_shared_from_this<Runtime>
42{
43public:
44 // Our default concurrency setup.
45 static constexpr const std::uint32_t worker_threads = 2;
46
47 // create returns a Runtime instance with pool_size worker threads
48 // executing the underlying service.
49 static std::shared_ptr<Runtime> create(std::uint32_t pool_size = worker_threads);
50
51 Runtime(const Runtime&) = delete;
52 Runtime(Runtime&&) = delete;
53 // Tears down the runtime, stopping all worker threads.
54 ~Runtime() noexcept(true);
55 Runtime& operator=(const Runtime&) = delete;
56 Runtime& operator=(Runtime&&) = delete;
57
58 // start executes the underlying io_service on a thread pool with
59 // the size configured at creation time.
60 void start();
61
62 // stop cleanly shuts down a Runtime instance,
63 // joining all worker threads.
64 void stop();
65
66 // to_dispatcher_functional returns a function for integration
67 // with components that expect a dispatcher for operation.
68 std::function<void(std::function<void()>)> to_dispatcher_functional();
69
70 // service returns the underlying boost::asio::io_service that is executed
71 // by the Runtime.
72 boost::asio::io_service& service();
73
74private:
75 // Runtime constructs a new instance, firing up pool_size
76 // worker threads.
77 Runtime(std::uint32_t pool_size);
78
79 std::uint32_t pool_size_;
80 boost::asio::io_service service_;
81 boost::asio::io_service::strand strand_;
82 boost::asio::io_service::work keep_alive_;
83 std::vector<std::thread> workers_;
84};
85}
86}
87}
88}
89
90#endif // COM_UBUNTU_LOCATION_SERVICE_RUNTIME_H_
091
=== modified file 'src/location_service/com/ubuntu/location/service/session/skeleton.cpp'
--- src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2014-08-14 20:31:09 +0000
+++ src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2016-01-13 12:31:53 +0000
@@ -283,7 +283,13 @@
283 VLOG(10) << __PRETTY_FUNCTION__;283 VLOG(10) << __PRETTY_FUNCTION__;
284 try284 try
285 {285 {
286 configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdatePosition, void>(position);286 configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdatePosition, void>([](const core::dbus::Result<void>& result)
287 {
288 if (result.is_error())
289 {
290 LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
291 }
292 }, position);
287 } catch(const std::exception&)293 } catch(const std::exception&)
288 {294 {
289 // We consider the session to be dead once we hit an exception here.295 // We consider the session to be dead once we hit an exception here.
@@ -300,7 +306,13 @@
300 VLOG(10) << __PRETTY_FUNCTION__;306 VLOG(10) << __PRETTY_FUNCTION__;
301 try307 try
302 {308 {
303 configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateHeading, void>(heading);309 configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateHeading, void>([](const core::dbus::Result<void>& result)
310 {
311 if (result.is_error())
312 {
313 LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
314 }
315 }, heading);
304 } catch(const std::exception&)316 } catch(const std::exception&)
305 {317 {
306 // We consider the session to be dead once we hit an exception here.318 // We consider the session to be dead once we hit an exception here.
@@ -317,7 +329,13 @@
317 VLOG(10) << __PRETTY_FUNCTION__;329 VLOG(10) << __PRETTY_FUNCTION__;
318 try330 try
319 {331 {
320 configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateVelocity, void>(velocity);332 configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateVelocity, void>([](const core::dbus::Result<void>& result)
333 {
334 if (result.is_error())
335 {
336 LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
337 }
338 }, velocity);
321 } catch(const std::exception&)339 } catch(const std::exception&)
322 {340 {
323 // We consider the session to be dead once we hit an exception here.341 // We consider the session to be dead once we hit an exception here.
324342
=== modified file 'src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp'
--- src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp 2014-09-19 14:36:51 +0000
+++ src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp 2016-01-13 12:31:53 +0000
@@ -146,7 +146,7 @@
146 return service::PermissionManager::Result::rejected;146 return service::PermissionManager::Result::rejected;
147 }147 }
148148
149 std::string description = i18n::tr("%1% wants to access your current location.");149 std::string description = i18n::tr("wants to access your current location.");
150150
151 core::trust::Agent::RequestParameters params151 core::trust::Agent::RequestParameters params
152 {152 {
153153
=== modified file 'src/location_service/com/ubuntu/location/time_based_update_policy.cpp'
--- src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2015-04-23 21:30:04 +0000
+++ src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2016-01-13 12:31:53 +0000
@@ -53,8 +53,9 @@
53 {53 {
54 // if the update has happened within a reasonable amount of time we will just use it if it is more accurate54 // if the update has happened within a reasonable amount of time we will just use it if it is more accurate
55 // that the previous one.55 // that the previous one.
56 use_new_update = last_position_update.value.accuracy.horizontal && update.value.accuracy.horizontal56 use_new_update = !last_position_update.value.accuracy.horizontal ||
57 && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal;57 (update.value.accuracy.horizontal
58 && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal);
58 }59 }
5960
60 if (use_new_update)61 if (use_new_update)
@@ -118,4 +119,4 @@
118119
119}120}
120}121}
121}
122\ No newline at end of file122\ No newline at end of file
123}
123124
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-04-23 17:04:09 +0000
+++ tests/CMakeLists.txt 2016-01-13 12:31:53 +0000
@@ -92,6 +92,7 @@
92LOCATION_SERVICE_ADD_TEST(provider_test provider_test.cpp)92LOCATION_SERVICE_ADD_TEST(provider_test provider_test.cpp)
93LOCATION_SERVICE_ADD_TEST(wgs84_test wgs84_test.cpp)93LOCATION_SERVICE_ADD_TEST(wgs84_test wgs84_test.cpp)
94LOCATION_SERVICE_ADD_TEST(trust_store_permission_manager_test trust_store_permission_manager_test.cpp)94LOCATION_SERVICE_ADD_TEST(trust_store_permission_manager_test trust_store_permission_manager_test.cpp)
95LOCATION_SERVICE_ADD_TEST(runtime_test runtime_test.cpp)
9596
96# Provider-specific test-cases go here.97# Provider-specific test-cases go here.
97if (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)98if (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
@@ -124,3 +125,4 @@
124125
125LOCATION_SERVICE_ADD_TEST(remote_provider_test remote_provider_test.cpp)126LOCATION_SERVICE_ADD_TEST(remote_provider_test remote_provider_test.cpp)
126LOCATION_SERVICE_ADD_TEST(espoo_provider_test espoo_provider_test.cpp)127LOCATION_SERVICE_ADD_TEST(espoo_provider_test espoo_provider_test.cpp)
128LOCATION_SERVICE_ADD_TEST(delayed_service_test delayed_service_test.cpp)
127129
=== modified file 'tests/acceptance_tests.cpp'
--- tests/acceptance_tests.cpp 2015-02-13 13:19:18 +0000
+++ tests/acceptance_tests.cpp 2016-01-13 12:31:53 +0000
@@ -38,12 +38,14 @@
38#include <com/ubuntu/location/service/stub.h>38#include <com/ubuntu/location/service/stub.h>
3939
40#include <core/dbus/announcer.h>40#include <core/dbus/announcer.h>
41#include <core/dbus/bus.h>
41#include <core/dbus/fixture.h>42#include <core/dbus/fixture.h>
42#include <core/dbus/resolver.h>43#include <core/dbus/resolver.h>
4344
44#include <core/dbus/asio/executor.h>45#include <core/dbus/asio/executor.h>
4546
46#include <core/posix/signal.h>47#include <core/posix/signal.h>
48#include <core/posix/this_process.h>
4749
48#include <core/testing/cross_process_sync.h>50#include <core/testing/cross_process_sync.h>
49#include <core/testing/fork_and_run.h>51#include <core/testing/fork_and_run.h>
@@ -663,6 +665,110 @@
663 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));665 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
664}666}
665667
668TEST_F(LocationServiceStandalone, NewSessionsGetLastKnownPosition)
669{
670 core::testing::CrossProcessSync sync_start;
671
672 auto server = [this, &sync_start]()
673 {
674 SCOPED_TRACE("Server");
675
676 auto trap = core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_term});
677 trap->signal_raised().connect([trap](core::posix::Signal)
678 {
679 trap->stop();
680 });
681
682 auto incoming = session_bus();
683 auto outgoing = session_bus();
684
685 incoming->install_executor(core::dbus::asio::make_executor(incoming));
686 outgoing->install_executor(core::dbus::asio::make_executor(outgoing));
687
688 auto dummy = new DummyProvider();
689 cul::Provider::Ptr helper(dummy);
690
691 cul::service::DefaultConfiguration config;
692 cul::service::Implementation::Configuration configuration
693 {
694 incoming,
695 outgoing,
696 config.the_engine(config.the_provider_set(helper), config.the_provider_selection_policy(), null_settings()),
697 config.the_permission_manager(incoming),
698 cul::service::Harvester::Configuration
699 {
700 cul::connectivity::platform_default_manager(),
701 std::make_shared<NullReporter>()
702 }
703 };
704 auto location_service = std::make_shared<cul::service::Implementation>(configuration);
705
706 configuration.engine->updates.last_known_location.set(reference_position_update);
707 std::thread t1{[incoming](){incoming->run();}};
708 std::thread t2{[outgoing](){outgoing->run();}};
709
710 sync_start.try_signal_ready_for(std::chrono::milliseconds{500});
711
712 trap->run();
713
714 incoming->stop();
715 outgoing->stop();
716
717 if (t1.joinable())
718 t1.join();
719
720 if (t2.joinable())
721 t2.join();
722
723 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
724 };
725
726 auto client = [this, &sync_start]()
727 {
728 SCOPED_TRACE("Client");
729
730 EXPECT_EQ(1, sync_start.wait_for_signal_ready_for(std::chrono::milliseconds{500}));
731
732 auto bus = session_bus();
733 bus->install_executor(dbus::asio::make_executor(bus));
734 std::thread t{[bus](){bus->run();}};
735
736 auto location_service = dbus::resolve_service_on_bus<
737 cul::service::Interface,
738 cul::service::Stub>(bus);
739
740 auto s1 = location_service->create_session_for_criteria(cul::Criteria{});
741
742 std::cout << "Successfully created session" << std::endl;
743
744 cul::Update<cul::Position> position;
745 auto c1 = s1->updates().position.changed().connect(
746 [&](const cul::Update<cul::Position>& new_position) {
747 std::cout << "On position updated: " << new_position << std::endl;
748 position = new_position;
749 });
750
751 std::cout << "Created event connections, starting updates..." << std::endl;
752
753 s1->updates().position_status = culss::Interface::Updates::Status::enabled;
754
755 std::cout << "done" << std::endl;
756
757 std::this_thread::sleep_for(std::chrono::milliseconds{1000});
758
759 bus->stop();
760
761 if (t.joinable())
762 t.join();
763
764 EXPECT_EQ(reference_position_update, position);
765
766 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
767 };
768
769 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
770}
771
666namespace772namespace
667{773{
668struct LocationServiceStandaloneLoad : public LocationServiceStandalone774struct LocationServiceStandaloneLoad : public LocationServiceStandalone
@@ -708,7 +814,7 @@
708814
709 options.add(Keys::update_period,815 options.add(Keys::update_period,
710 "Update period length for dummy::Provider setup.",816 "Update period length for dummy::Provider setup.",
711 std::uint32_t{100});817 std::uint32_t{10});
712818
713 options.add(Keys::client_count,819 options.add(Keys::client_count,
714 "Number of clients that should be fired up.",820 "Number of clients that should be fired up.",
@@ -761,6 +867,8 @@
761};867};
762}868}
763869
870#include "did_finish_successfully.h"
871
764TEST_F(LocationServiceStandaloneLoad, MultipleClientsConnectingAndDisconnectingWorks)872TEST_F(LocationServiceStandaloneLoad, MultipleClientsConnectingAndDisconnectingWorks)
765{873{
766 EXPECT_TRUE(trust_store_is_set_up_for_testing);874 EXPECT_TRUE(trust_store_is_set_up_for_testing);
@@ -801,8 +909,8 @@
801 };909 };
802910
803 cul::service::Daemon::Configuration config;911 cul::service::Daemon::Configuration config;
804 config.incoming = session_bus();912 config.incoming = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
805 config.outgoing = session_bus();913 config.outgoing = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
806 config.is_testing_enabled = false;914 config.is_testing_enabled = false;
807 config.providers =915 config.providers =
808 {916 {
@@ -829,7 +937,7 @@
829 status;937 status;
830 }, core::posix::StandardStream::empty);938 }, core::posix::StandardStream::empty);
831939
832 std::this_thread::sleep_for(std::chrono::seconds{2});940 std::this_thread::sleep_for(std::chrono::seconds{15});
833941
834 auto client = [this]()942 auto client = [this]()
835 {943 {
@@ -957,17 +1065,11 @@
957 {1065 {
958 VLOG(1) << "Stopping client...: " << client.pid();1066 VLOG(1) << "Stopping client...: " << client.pid();
959 client.send_signal_or_throw(core::posix::Signal::sig_term);1067 client.send_signal_or_throw(core::posix::Signal::sig_term);
960 auto result = client.wait_for(core::posix::wait::Flags::untraced);1068 EXPECT_TRUE(did_finish_successfully(client.wait_for(core::posix::wait::Flags::untraced)));
961
962 EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
963 EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
964 }1069 }
9651070
966 VLOG(1) << "Cleaned up clients, shutting down the service...";1071 VLOG(1) << "Cleaned up clients, shutting down the service...";
9671072
968 server.send_signal_or_throw(core::posix::Signal::sig_term);1073 server.send_signal_or_throw(core::posix::Signal::sig_term);
969 auto result = server.wait_for(core::posix::wait::Flags::untraced);1074 EXPECT_TRUE(did_finish_successfully(server.wait_for(core::posix::wait::Flags::untraced)));
970
971 EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
972 EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
973}1075}
9741076
=== added file 'tests/delayed_service_test.cpp'
--- tests/delayed_service_test.cpp 1970-01-01 00:00:00 +0000
+++ tests/delayed_service_test.cpp 2016-01-13 12:31:53 +0000
@@ -0,0 +1,193 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Scott Sweeny <scott.sweeny@canonical.com>
18 */
19
20#include <com/ubuntu/location/service/daemon.h>
21#include <com/ubuntu/location/service/provider_daemon.h>
22#include <com/ubuntu/location/providers/remote/provider.h>
23
24#include <com/ubuntu/location/service/stub.h>
25
26#include <com/ubuntu/location/position.h>
27#include <com/ubuntu/location/update.h>
28
29#include <core/dbus/fixture.h>
30
31#include <core/dbus/asio/executor.h>
32
33#include <core/posix/fork.h>
34#include <core/posix/signal.h>
35#include <core/posix/this_process.h>
36
37#include "did_finish_successfully.h"
38#include "mock_event_receiver.h"
39
40#include <gmock/gmock.h>
41
42namespace location = com::ubuntu::location;
43namespace remote = com::ubuntu::location::providers::remote;
44
45namespace
46{
47struct DelayedServiceTest : public core::dbus::testing::Fixture, public ::testing::WithParamInterface<int>
48{
49
50};
51}
52
53TEST_P(DelayedServiceTest, AClientReceivesUpdatesFromADelayedProvider)
54{
55 auto oopp = core::posix::fork([this]()
56 {
57 auto bus = session_bus();
58
59 // Pass the delay value to the provider
60 char delay[50];
61 sprintf(delay, "--dummy::DelayedProvider::DelayInMs=%d", GetParam());
62
63 const char* argv[] =
64 {
65 "--bus", "session", // 2
66 "--service-name", "com.ubuntu.location.providers.Dummy", // 4
67 "--service-path", "/com/ubuntu/location/providers/Dummy", // 6
68 "--provider", "dummy::DelayedProvider", // 8
69 delay // 9
70 };
71
72 auto dbus_connection_factory = [bus](core::dbus::WellKnownBus)
73 {
74 return bus;
75 };
76
77 return static_cast<core::posix::exit::Status>(
78 location::service::ProviderDaemon::main(
79 location::service::ProviderDaemon::Configuration::from_command_line_args(
80 9, argv, dbus_connection_factory)));
81 }, core::posix::StandardStream::empty);
82
83 std::this_thread::sleep_for(std::chrono::milliseconds{250});
84
85 auto service = core::posix::fork([this]()
86 {
87 core::posix::this_process::env::set_or_throw(
88 "TRUST_STORE_PERMISSION_MANAGER_IS_RUNNING_UNDER_TESTING",
89 "1");
90
91 const char* argv[] =
92 {
93 "--bus", "session", // 2
94 "--provider", "remote::Provider", // 4
95 "--remote::Provider::bus=session_with_address_from_env", // 5
96 "--remote::Provider::name=com.ubuntu.location.providers.Dummy", // 6
97 "--remote::Provider::path=/com/ubuntu/location/providers/Dummy" // 7
98 };
99
100 // The daemon instance requires two bus instances.
101 auto dbus_connection_factory = [this](core::dbus::WellKnownBus)
102 {
103 return session_bus();
104 };
105
106 return static_cast<core::posix::exit::Status>(
107 location::service::Daemon::main(
108 location::service::Daemon::Configuration::from_command_line_args(
109 7, argv, dbus_connection_factory)));
110 }, core::posix::StandardStream::empty);
111
112 // Wait to setup the client until the service is up
113 std::this_thread::sleep_for(std::chrono::milliseconds{250 + GetParam()});
114
115 auto client = core::posix::fork([this]()
116 {
117 using namespace ::testing;
118
119 auto trap = core::posix::trap_signals_for_all_subsequent_threads(
120 {
121 core::posix::Signal::sig_term,
122 core::posix::Signal::sig_int
123 });
124
125 trap->signal_raised().connect([trap](const core::posix::Signal&)
126 {
127 trap->stop();
128 });
129
130 auto bus = session_bus();
131 bus->install_executor(core::dbus::asio::make_executor(bus));
132
133 std::thread worker
134 {
135 [bus]() { bus->run(); }
136 };
137
138 MockEventReceiver receiver;
139 EXPECT_CALL(receiver, position_update_received(_)).Times(AtLeast(1));
140 EXPECT_CALL(receiver, heading_update_received(_)).Times(AtLeast(1));
141 EXPECT_CALL(receiver, velocity_update_received(_)).Times(AtLeast(1));
142
143 com::ubuntu::location::service::Stub service{bus};
144
145 auto session = service.create_session_for_criteria(location::Criteria{});
146
147 session->updates().position.changed().connect([&receiver](location::Update<location::Position> pos)
148 {
149 receiver.position_update_received(pos);
150 });
151
152 session->updates().heading.changed().connect([&receiver](location::Update<location::Heading> heading)
153 {
154 receiver.heading_update_received(heading);
155 });
156
157 session->updates().velocity.changed().connect([&receiver](location::Update<location::Velocity> velocity)
158 {
159 receiver.velocity_update_received(velocity);
160 });
161
162 session->updates().position_status = location::service::session::Interface::Updates::Status::enabled;
163 session->updates().velocity_status = location::service::session::Interface::Updates::Status::enabled;
164 session->updates().heading_status = location::service::session::Interface::Updates::Status::enabled;
165
166 trap->run();
167
168 bus->stop();
169
170 if (worker.joinable())
171 worker.join();
172
173 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure :
174 core::posix::exit::Status::success;
175 }, core::posix::StandardStream::empty);
176
177 std::this_thread::sleep_for(std::chrono::milliseconds{4000});
178
179 std::cout << "Shutting down client" << std::endl;
180 client.send_signal_or_throw(core::posix::Signal::sig_term);
181 EXPECT_TRUE(did_finish_successfully(client.wait_for(core::posix::wait::Flags::untraced)));
182
183 std::cout << "Shutting down service" << std::endl;
184 service.send_signal_or_throw(core::posix::Signal::sig_term);
185 EXPECT_TRUE(did_finish_successfully(service.wait_for(core::posix::wait::Flags::untraced)));
186
187 std::cout << "Shutting down oopp" << std::endl;
188 oopp.send_signal_or_throw(core::posix::Signal::sig_term);
189 EXPECT_TRUE(did_finish_successfully(oopp.wait_for(core::posix::wait::Flags::untraced)));
190}
191
192INSTANTIATE_TEST_CASE_P(ServiceDelays, DelayedServiceTest,
193 ::testing::Values(0, 250, 500, 1000, 2000, 5000, 10000));
0194
=== modified file 'tests/engine_test.cpp'
--- tests/engine_test.cpp 2015-01-21 20:04:56 +0000
+++ tests/engine_test.cpp 2016-01-13 12:31:53 +0000
@@ -154,9 +154,9 @@
154 EXPECT_CALL(*provider, on_reference_velocity_updated(_)).Times(1);154 EXPECT_CALL(*provider, on_reference_velocity_updated(_)).Times(1);
155155
156 engine.configuration.wifi_and_cell_id_reporting_state = location::WifiAndCellIdReportingState::on;156 engine.configuration.wifi_and_cell_id_reporting_state = location::WifiAndCellIdReportingState::on;
157 engine.updates.reference_location = location::Update<location::Position>{};157 engine.updates.last_known_location = location::Update<location::Position>{};
158 engine.updates.reference_heading = location::Update<location::Heading>{};158 engine.updates.last_known_heading = location::Update<location::Heading>{};
159 engine.updates.reference_velocity = location::Update<location::Velocity>{};159 engine.updates.last_known_velocity = location::Update<location::Velocity>{};
160}160}
161161
162/* TODO(tvoss): We have to disable these tests as the MP is being refactored to not break ABI.162/* TODO(tvoss): We have to disable these tests as the MP is being refactored to not break ABI.
163163
=== modified file 'tests/gps_provider_test.cpp'
--- tests/gps_provider_test.cpp 2015-01-12 08:41:14 +0000
+++ tests/gps_provider_test.cpp 2016-01-13 12:31:53 +0000
@@ -48,6 +48,31 @@
4848
49namespace49namespace
50{50{
51
52struct MockHardwareGps
53{
54 MockHardwareGps()
55 {
56 instance_ = this;
57 }
58 ~MockHardwareGps()
59 {
60 instance_ = nullptr;
61 }
62
63 MOCK_METHOD5(set_position_mode, bool(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t));
64 MOCK_METHOD3(inject_time, void(int64_t, int64_t, int));
65
66 static MockHardwareGps *mocked(UHardwareGps self) {
67 return reinterpret_cast<MockHardwareGps*>(self);
68 }
69 static MockHardwareGps *instance() { return instance_; }
70
71 static MockHardwareGps *instance_;
72};
73
74MockHardwareGps *MockHardwareGps::instance_ = nullptr;
75
51struct UpdateTrap76struct UpdateTrap
52{77{
53 MOCK_METHOD1(on_position_updated, void(const location::Position&));78 MOCK_METHOD1(on_position_updated, void(const location::Position&));
@@ -211,6 +236,42 @@
211236
212}237}
213238
239/* Mock the hardware GPS platform API: the methods defined here will be invoked
240 * instead of those exported by the system library.
241 * We redefine these methods using the MockHardwareGps class above, which is
242 * implemented using google-mock. This effectively allows us to test that the
243 * right calls to the platform API are made.
244 */
245UHardwareGps
246u_hardware_gps_new(UHardwareGpsParams *)
247{
248 using namespace ::testing;
249
250 return reinterpret_cast<UHardwareGps>(MockHardwareGps::instance());
251}
252
253void
254u_hardware_gps_delete(UHardwareGps)
255{
256}
257
258bool
259u_hardware_gps_set_position_mode(UHardwareGps self, uint32_t mode, uint32_t recurrence,
260 uint32_t min_interval, uint32_t preferred_accuracy,
261 uint32_t preferred_time)
262{
263 MockHardwareGps *thiz = MockHardwareGps::mocked(self);
264 return thiz->set_position_mode(mode, recurrence, min_interval,
265 preferred_accuracy, preferred_time);
266}
267
268void
269u_hardware_gps_inject_time(UHardwareGps self, int64_t time, int64_t time_reference, int uncertainty)
270{
271 MockHardwareGps* thiz = MockHardwareGps::mocked(self);
272 return thiz->inject_time(time, time_reference, uncertainty);
273}
274
214TEST(AndroidGpsXtraDownloader, reading_configuration_from_valid_conf_file_works)275TEST(AndroidGpsXtraDownloader, reading_configuration_from_valid_conf_file_works)
215{276{
216 std::stringstream ss{gps_conf};277 std::stringstream ss{gps_conf};
@@ -261,6 +322,28 @@
261 provider.on_reference_location_updated(pos);322 provider.on_reference_location_updated(pos);
262}323}
263324
325TEST(GpsProvider, time_requests_inject_current_time_into_the_hal)
326{
327 using namespace ::testing;
328
329 NiceMock<MockHardwareGps> hardwareGps;
330
331 gps::android::HardwareAbstractionLayer::Configuration configuration;
332 gps::android::HardwareAbstractionLayer hal(configuration);
333 std::shared_ptr<gps::HardwareAbstractionLayer> hal_ptr(&hal, [](gps::HardwareAbstractionLayer*){});
334
335 gps::Provider provider(hal_ptr);
336 int64_t time = 0;
337 EXPECT_CALL(hardwareGps, inject_time(_, _, 0)).Times(1).WillOnce(SaveArg<0>(&time));
338
339 auto t0 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
340
341 gps::android::HardwareAbstractionLayer::on_request_utc_time(&hal);
342
343 auto t1 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
344 EXPECT_THAT(time, AllOf(Ge(t0.count()), Le(t1.count())));
345}
346
264TEST(GpsProvider, updates_from_hal_are_passed_on_by_the_provider)347TEST(GpsProvider, updates_from_hal_are_passed_on_by_the_provider)
265{348{
266 using namespace ::testing;349 using namespace ::testing;
267350
=== added file 'tests/mock_event_receiver.h'
--- tests/mock_event_receiver.h 1970-01-01 00:00:00 +0000
+++ tests/mock_event_receiver.h 2016-01-13 12:31:53 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Scott Sweeny <scott.sweeny@canonical.com>
18 */
19#ifndef MOCK_EVENT_RECEIVER_H_
20#define MOCK_EVENT_RECEIVER_H_
21
22#include <com/ubuntu/location/update.h>
23
24#include <gmock/gmock.h>
25
26namespace location = com::ubuntu::location;
27
28struct MockEventReceiver
29{
30 MOCK_METHOD1(position_update_received, void(const location::Update<location::Position>&));
31 MOCK_METHOD1(heading_update_received, void(const location::Update<location::Heading>&));
32 MOCK_METHOD1(velocity_update_received, void(const location::Update<location::Velocity>&));
33};
34
35#endif // MOCK_EVENT_RECEIVER_H_
036
=== modified file 'tests/position_test.cpp'
--- tests/position_test.cpp 2014-06-20 07:40:34 +0000
+++ tests/position_test.cpp 2016-01-13 12:31:53 +0000
@@ -40,7 +40,7 @@
40 cul::wgs84::Latitude{},40 cul::wgs84::Latitude{},
41 cul::wgs84::Longitude{},41 cul::wgs84::Longitude{},
42 cul::wgs84::Altitude{}};42 cul::wgs84::Altitude{}};
43 EXPECT_TRUE(p.altitude);43 EXPECT_TRUE(p.altitude ? true : false);
44}44}
4545
46#include <com/ubuntu/location/codec.h>46#include <com/ubuntu/location/codec.h>
4747
=== modified file 'tests/remote_providerd_test.cpp'
--- tests/remote_providerd_test.cpp 2014-10-27 21:58:16 +0000
+++ tests/remote_providerd_test.cpp 2016-01-13 12:31:53 +0000
@@ -31,6 +31,7 @@
31#include <core/posix/fork.h>31#include <core/posix/fork.h>
3232
33#include "did_finish_successfully.h"33#include "did_finish_successfully.h"
34#include "mock_event_receiver.h"
3435
35#include <gmock/gmock.h>36#include <gmock/gmock.h>
3637
@@ -38,13 +39,6 @@
3839
39namespace40namespace
40{41{
41struct MockEventReceiver
42{
43 MOCK_METHOD1(position_update_received, void(const location::Update<location::Position>&));
44 MOCK_METHOD1(heading_update_received, void(const location::Update<location::Heading>&));
45 MOCK_METHOD1(velocity_update_received, void(const location::Update<location::Velocity>&));
46};
47
48struct RemoteProviderdTest : public core::dbus::testing::Fixture42struct RemoteProviderdTest : public core::dbus::testing::Fixture
49{43{
5044
5145
=== added file 'tests/runtime_test.cpp'
--- tests/runtime_test.cpp 1970-01-01 00:00:00 +0000
+++ tests/runtime_test.cpp 2016-01-13 12:31:53 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright © 2015Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#include <com/ubuntu/location/service/runtime.h>
19
20#include <gtest/gtest.h>
21
22#include <condition_variable>
23#include <thread>
24
25namespace culs = com::ubuntu::location::service;
26
27TEST(Runtime, cleanly_shuts_down_threads)
28{
29 culs::Runtime::create();
30}
31
32TEST(Runtime, executes_service)
33{
34 std::mutex m;
35 std::unique_lock<std::mutex> ul{m};
36 std::condition_variable wc;
37
38 bool signaled = false;
39
40 auto rt = culs::Runtime::create();
41 rt->start();
42 boost::asio::deadline_timer timer{rt->service(), boost::posix_time::milliseconds(500)};
43 timer.async_wait([&wc, &signaled](const boost::system::error_code&)
44 {
45 signaled = true;
46 wc.notify_all();
47 });
48
49 auto result = wc.wait_for(ul, std::chrono::seconds{1}, [&signaled]() { return signaled; });
50 EXPECT_TRUE(result);
51}
52
53TEST(Runtime, catches_exceptions_thrown_from_handlers)
54{
55 std::mutex m;
56 std::unique_lock<std::mutex> ul{m};
57 std::condition_variable wc;
58
59 bool signaled = false;
60
61 auto rt = culs::Runtime::create();
62 rt->start();
63 boost::asio::deadline_timer fast{rt->service(), boost::posix_time::milliseconds(100)};
64 fast.async_wait([](const boost::system::error_code&)
65 {
66 throw std::runtime_error{"Should not propagate"};
67 });
68
69 boost::asio::deadline_timer slow{rt->service(), boost::posix_time::milliseconds(500)};
70 slow.async_wait([&wc, &signaled](const boost::system::error_code&)
71 {
72 signaled = true;
73 wc.notify_all();
74 });
75
76 auto result = wc.wait_for(ul, std::chrono::seconds{1}, [&signaled]() { return signaled; });
77 EXPECT_TRUE(result);
78}
79
80// sets_up_pool_of_threads ensures that the pool size
81// passed to the Runtime on construction is honored. The idea is simple:
82// We set up two deadline timers, fast and slow. fast fires before slow,
83// with fast blocking in a wait on a common condition_variable. When slow
84// fires, it notifies the condition variable, thereby unblocking the handler of fast,
85// enabling clean shutdown without errors and timeouts. This only works if the
86// pool contains at least 2 threads. Otherwise, the handler of slow would not be executed
87// until the handler of fast times out in the wait, marking the test as failed.
88TEST(Runtime, sets_up_pool_of_threads)
89{
90 struct State
91 {
92 bool signaled{false};
93 std::mutex m;
94 std::condition_variable wc;
95 };
96
97 auto state = std::make_shared<State>();
98
99 auto rt = culs::Runtime::create(2);
100 rt->start();
101 boost::asio::deadline_timer fast{rt->service(), boost::posix_time::milliseconds(100)};
102 fast.async_wait([state](const boost::system::error_code&)
103 {
104 std::unique_lock<std::mutex> ul{state->m};
105 EXPECT_TRUE(state->wc.wait_for(ul, std::chrono::seconds{1}, [state]() { return state->signaled; }));
106 });
107
108 boost::asio::deadline_timer slow{rt->service(), boost::posix_time::milliseconds(500)};
109 slow.async_wait([state](const boost::system::error_code&)
110 {
111 state->signaled = true;
112 state->wc.notify_all();
113 });
114
115 std::unique_lock<std::mutex> ul{state->m};
116 auto result = state->wc.wait_for(ul, std::chrono::seconds{1}, [state]() { return state->signaled; });
117 EXPECT_TRUE(result);
118}
0119
=== added directory 'tools'
=== added file 'tools/CMakeLists.txt'
--- tools/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tools/CMakeLists.txt 2016-01-13 12:31:53 +0000
@@ -0,0 +1,1 @@
1configure_file(symbol_diff.in symbol_diff)
02
=== added file 'tools/symbol_diff.in'
--- tools/symbol_diff.in 1970-01-01 00:00:00 +0000
+++ tools/symbol_diff.in 2016-01-13 12:31:53 +0000
@@ -0,0 +1,70 @@
1#! /usr/bin/env python3
2
3#
4# Copyright (C) 2014 Canonical Ltd
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Lesser General Public License version 3 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# Authored by: Michi Henning <michi.henning@canonical.com>
19#
20
21import re
22import subprocess
23
24OLD_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.symbols'
25NEW_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@/DEBIAN/symbols'
26
27def run():
28 old_regex = re.compile(r'^ (\(.*\))"(.*)" (.*)$')
29
30 old_syms = {} # Dictionary containing symbol -> ( tag, version )
31 with open(OLD_FILE, encoding='utf=8') as file:
32 file.readline() # Skip first line, which is the library name and version
33 for line in file:
34 mo = old_regex.match(line)
35 if mo:
36 old_syms[mo.group(2)] = ( mo.group(1), mo.group(3) )
37 else:
38 raise Exception('Invalid input line in ' + OLD_FILE + ': ' + line)
39
40 new_regex = re.compile(r'^ (.*) .+$')
41
42 # Run the new symbols file through "c++filt | sort | uniq". We need
43 # the sort | uniq because, otherwise, we end up with duplicate demangled symbols.
44 with open(NEW_FILE) as infile, open('new_symbols', 'w') as outfile:
45 p = subprocess.Popen(['c++filt | sort | uniq'], shell=True, stdin=infile, stdout=subprocess.PIPE)
46
47 # For each symbol, if it is in the old dictionary, output the tags from the original
48 # symbol file, followed by the symbol and version. Otherwise, use "(c++)" as the tag
49 # and add " 0replaceme", so the new symbol will be accepted.
50 line = p.stdout.readline().decode('utf-8')
51 outfile.write(line) # Write library name and version
52 for line in p.stdout:
53 mo = new_regex.match(line.decode('utf-8'))
54 if (mo):
55 sym = mo.group(1)
56 try:
57 tag, version = old_syms[sym]
58 except KeyError:
59 tag = '(c++)'
60 version = '0replaceme'
61 outfile.write(' {}"{}" {}\n'.format(tag, sym, version))
62 else:
63 raise Exception('Cannot parse demangled line: ' + line)
64
65 # Write the diff into /tmp/symbols.diff
66 with open('/tmp/symbols.diff', 'w') as outfile:
67 subprocess.call(['diff', '-u', OLD_FILE, 'new_symbols'], stdout=outfile)
68
69if __name__ == '__main__':
70 run()

Subscribers

People subscribed via source and target branches