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

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

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

Commit message

Enable dual landing.

Description of the change

Enable dual landing.

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

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

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

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

review: Needs Fixing (packaging)

Unmerged revisions

228. By Thomas Voß

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

227. By Thomas Voß

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

226. By Thomas Voß

Lower client count to make test more robust.

225. By Thomas Voß

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

224. By Thomas Voß

Fix s/lsp/lsb/ typo.

223. By Thomas Voß

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

222. By Thomas Voß

Add missing build-dep on lsb-release.

221. By Thomas Voß

Account for versioned include dir.

220. By Thomas Voß

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

219. By Thomas Voß

Enable dual landing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-09-18 23:06:08 +0000
+++ CMakeLists.txt 2016-01-18 13:07:31 +0000
@@ -2,9 +2,34 @@
22
3project(ubuntu-location-service)3project(ubuntu-location-service)
44
5set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 2)5# We haven't received version information via the packaging setup.
6set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0)6# For that, we try to determine sensible values on our own, ensuring
7set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 0)7# plain old invocations to cmake still work as expected.
8if (NOT DEFINED UBUNTU_LOCATION_SERVICE_VERSION_MAJOR)
9 find_program(LSB_RELEASE lsb_release)
10 execute_process(
11 COMMAND ${LSB_RELEASE} -c -s
12 OUTPUT_VARIABLE DISTRO_CODENAME
13 OUTPUT_STRIP_TRAILING_WHITESPACE)
14
15 # We explicitly ignore errors and only check if we are building for vivid.
16 # For all other cases:
17 # - releases other than vivid
18 # - other distros
19 # - errors
20 # we define the version to be 2.0.0
21 if (${DISTRO_CODENAME} STREQUAL "vivid")
22 set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 2)
23 set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0)
24 set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 0)
25 else ()
26 set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 3)
27 set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0)
28 set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 0)
29 endif()
30endif()
31
32message(STATUS "${CMAKE_PROJECT_NAME} ${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR}.${UBUNTU_LOCATION_SERVICE_VERSION_MINOR}.${UBUNTU_LOCATION_SERVICE_VERSION_PATCH}")
833
9set(UBUNTU_LOCATION_SERVICE_TRUST_STORE_SERVICE_NAME "UbuntuLocationService")34set(UBUNTU_LOCATION_SERVICE_TRUST_STORE_SERVICE_NAME "UbuntuLocationService")
1035
@@ -54,6 +79,20 @@
54 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")79 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
55endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)80endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
5681
82#
83# Code style fixer. We rely on clang-format to adjust the formatting of source code.
84#
85find_program(CLANG_FORMAT_COMMAND NAMES clang-format-3.6 clang-format-3.5)
86if (NOT CLANG_FORMAT_COMMAND)
87 message(WARNING "Cannot find clang-format >= clang-format-3.5: formatcode target will not be available")
88endif()
89
90if (CLANG_FORMAT_COMMAND)
91 file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h)
92 file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES ${CMAKE_SOURCE_DIR}/src/*.h ${CMAKE_SOURCE_DIR}/src/*.cpp)
93 add_custom_target(formatcode ${CLANG_FORMAT_COMMAND} -i ${UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES} ${UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES} SOURCES _clang-format)
94endif()
95
57include_directories(96include_directories(
58 ${Boost_INCLUDE_DIRS}97 ${Boost_INCLUDE_DIRS}
59 ${DBUS_INCLUDE_DIRS}98 ${DBUS_INCLUDE_DIRS}
6099
=== added file '_clang-format'
--- _clang-format 1970-01-01 00:00:00 +0000
+++ _clang-format 2016-01-18 13:07:31 +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-18 13:07:31 +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
=== added file 'debian/VERSION'
--- debian/VERSION 1970-01-01 00:00:00 +0000
+++ debian/VERSION 2016-01-18 13:07:31 +0000
@@ -0,0 +1,1 @@
13.0.0
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'debian/VERSION.vivid'
--- debian/VERSION.vivid 1970-01-01 00:00:00 +0000
+++ debian/VERSION.vivid 2016-01-18 13:07:31 +0000
@@ -0,0 +1,1 @@
12.0.0
02
=== modified file 'debian/changelog'
--- debian/changelog 2015-07-27 18:07:37 +0000
+++ debian/changelog 2016-01-18 13:07:31 +0000
@@ -1,3 +1,16 @@
1location-service (3.0.0-0ubuntu2) wily; urgency=medium
2
3 * libubuntu-location-service3: Replaces libubuntu-location-service2,
4 config file /etc/gps.conf in both packages.
5
6 -- Matthias Klose <doko@ubuntu.com> Thu, 30 Jul 2015 09:57:50 +0200
7
8location-service (3.0.0) wily; urgency=medium
9
10 * Bump major revision and fix LP:#1478750 to account for toolchain update.
11
12 -- Thomas Voß <thomas.voss@canonical.com> Thu, 30 Jul 2015 08:33:13 +0200
13
1location-service (2.1+15.10.20150727-0ubuntu1) wily; urgency=medium14location-service (2.1+15.10.20150727-0ubuntu1) wily; urgency=medium
215
3 [ CI Train Bot ]16 [ CI Train Bot ]
@@ -36,6 +49,74 @@
3649
37 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +000050 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +0000
3851
52location-service (2.1+15.04.20151202.1-0ubuntu1) vivid; urgency=medium
53
54 * Ensure that event connections are cleaned up on destruction. (LP:
55 #1480877)
56
57 -- Thomas Voß <ci-train-bot@canonical.com> Wed, 02 Dec 2015 12:12:21 +0000
58
59location-service (2.1+15.04.20151127-0ubuntu1) vivid; urgency=medium
60
61 [ Alberto Mardegan ]
62 * Send last known position on session start
63
64 [ CI Train Bot ]
65 * New rebuild forced.
66
67 [ Thomas Voß ]
68 * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
69 pair of files. Add test cases around correct operation of
70 service::Runtime. added:
71 src/location_service/com/ubuntu/location/service/runtime.cpp
72 src/location_service/com/ubuntu/location/service/runtime.h
73 tests/runtime_test.cpp
74
75 [ thomas-voss ]
76 * Factor out service::Runtime from daemon.cpp into its own .h/.cpp
77 pair of files. Add test cases around correct operation of
78 service::Runtime. added:
79 src/location_service/com/ubuntu/location/service/runtime.cpp
80 src/location_service/com/ubuntu/location/service/runtime.h
81 tests/runtime_test.cpp
82
83 -- Thomas Voß <ci-train-bot@canonical.com> Fri, 27 Nov 2015 13:00:33 +0000
84
85location-service (2.1+15.04.20151113-0ubuntu1) vivid; urgency=medium
86
87 * Adjust default timeout for downloading GPS XTRA data.
88
89 -- Thomas Voß <ci-train-bot@canonical.com> Fri, 13 Nov 2015 10:33:56 +0000
90
91location-service (2.1+15.04.20151109.2-0ubuntu1) vivid; urgency=medium
92
93 [ Alberto Mardegan ]
94 * Make sure that injected time is given in milliseconds
95
96 [ Thomas Voß ]
97 * Cherry-pick rev. 196 and 199 from lp:location-service. The changes
98 got accidentally removed by merging the outstanding documentation
99 branch.
100 * Handle responses of clients to updates asynchronously. Rely on
101 dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
102 #1462664, #1387643)
103
104 -- David Barth <david.barth@canonical.com> Mon, 09 Nov 2015 20:48:48 +0000
105
106location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium
107
108 [ Thomas Voß ]
109 * Add documentation for debugging, hacking and debugging the location
110 service. Pull manual testing instructions over from the wiki. Add
111 tools for formatting the source.
112
113 [ thomas-voss ]
114 * Add documentation for debugging, hacking and debugging the location
115 service. Pull manual testing instructions over from the wiki. Add
116 tools for formatting the source.
117
118 -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000
119
39location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium120location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium
40121
41 [ CI Train Bot ]122 [ CI Train Bot ]
42123
=== modified file 'debian/control'
--- debian/control 2015-07-15 19:04:43 +0000
+++ debian/control 2016-01-18 13:07:31 +0000
@@ -1,3 +1,8 @@
1# This file is autogenerated. DO NOT EDIT!
2#
3# Modifications should be made to control.in instead.
4# This file is regenerated automatically in the clean target.
5#
1Source: location-service6Source: location-service
2Section: utils7Section: utils
3Priority: optional8Priority: optional
@@ -27,6 +32,7 @@
27 libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],32 libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],
28 libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],33 libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],
29 libproperties-cpp-dev,34 libproperties-cpp-dev,
35 lsb-release,
30 trust-store-bin,36 trust-store-bin,
31Standards-Version: 3.9.437Standards-Version: 3.9.4
32Homepage: http://launchpad.net/location-service38Homepage: http://launchpad.net/location-service
@@ -35,7 +41,7 @@
35Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk41Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk
36Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files42Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files
3743
38Package: libubuntu-location-service244Package: libubuntu-location-service3
39Section: libs45Section: libs
40Architecture: any46Architecture: any
41Multi-Arch: same47Multi-Arch: same
@@ -52,7 +58,7 @@
52Architecture: any58Architecture: any
53Multi-Arch: foreign59Multi-Arch: foreign
54Recommends: ubuntu-location-service-doc,60Recommends: ubuntu-location-service-doc,
55Depends: libubuntu-location-service2 (= ${binary:Version}),61Depends: libubuntu-location-service3 (= ${binary:Version}),
56 libdbus-1-dev,62 libdbus-1-dev,
57 libdbus-cpp-dev,63 libdbus-cpp-dev,
58 libboost-dev,64 libboost-dev,
@@ -68,7 +74,7 @@
68Section: debug74Section: debug
69Architecture: any75Architecture: any
70Multi-Arch: foreign76Multi-Arch: foreign
71Depends: libubuntu-location-service2 (= ${binary:Version}),77Depends: libubuntu-location-service3 (= ${binary:Version}),
72 ${misc:Depends},78 ${misc:Depends},
73Description: location service aggregating position/velocity/heading79Description: location service aggregating position/velocity/heading
74 updates and exporting them over dbus.80 updates and exporting them over dbus.
@@ -86,7 +92,7 @@
8692
87Package: ubuntu-location-service-bin93Package: ubuntu-location-service-bin
88Architecture: any94Architecture: any
89Depends: libubuntu-location-service2 (= ${binary:Version}),95Depends: libubuntu-location-service3 (= ${binary:Version}),
90 ${misc:Depends},96 ${misc:Depends},
91 ${shlibs:Depends},97 ${shlibs:Depends},
92 trust-store-bin,98 trust-store-bin,
@@ -100,7 +106,7 @@
100Package: ubuntu-location-service-examples106Package: ubuntu-location-service-examples
101Architecture: any107Architecture: any
102Multi-Arch: same108Multi-Arch: same
103Depends: libubuntu-location-service2 (= ${binary:Version}),109Depends: libubuntu-location-service3 (= ${binary:Version}),
104 ${misc:Depends},110 ${misc:Depends},
105 ${shlibs:Depends},111 ${shlibs:Depends},
106 ubuntu-location-service-doc,112 ubuntu-location-service-doc,
107113
=== added file 'debian/control.in'
--- debian/control.in 1970-01-01 00:00:00 +0000
+++ debian/control.in 2016-01-18 13:07:31 +0000
@@ -0,0 +1,123 @@
1Source: location-service
2Section: utils
3Priority: optional
4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5XSBC-Original-Maintainer: Thomas Voß <thomas.voss@canonical.com>
6Build-Depends: cmake,
7 curl,
8 libdbus-cpp-dev (>= 4.1.0),
9 debhelper (>= 9),
10 doxygen,
11 geoclue-ubuntu-geoip,
12 google-mock (>= 1.6.0+svn437),
13 graphviz,
14 libapparmor-dev,
15 libboost-filesystem-dev,
16 libboost-program-options-dev,
17 libboost-system-dev,
18 libdbus-1-dev,
19 libdbus-cpp-dev,
20 libgoogle-glog-dev,
21 libgtest-dev,
22 libiw-dev,
23 libjson-c-dev,
24 libnet-cpp-dev,
25 libprocess-cpp-dev,
26 libtrust-store-dev,
27 libubuntu-platform-hardware-api-headers [!arm64 !ppc64el !powerpc],
28 libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc],
29 libproperties-cpp-dev,
30 lsb-release,
31 trust-store-bin,
32Standards-Version: 3.9.4
33Homepage: http://launchpad.net/location-service
34# If you aren't a member of ~phablet-team but need to upload packaging changes,
35# just go ahead. ~phablet-team will notice and sync up the code again.
36Vcs-Bzr: https://code.launchpad.net/~phablet-team/location-service/trunk
37Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/location-service/trunk/files
38
39Package: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@
40Section: libs
41Architecture: any
42Multi-Arch: same
43Pre-Depends: ${misc:Pre-Depends}
44Depends: ${misc:Depends},
45 ${shlibs:Depends},
46Description: location service aggregating position/velocity/heading
47 updates and exporting them over dbus.
48 .
49 Contains the shared library needed by client applications.
50
51Package: libubuntu-location-service-dev
52Section: libdevel
53Architecture: any
54Multi-Arch: foreign
55Recommends: ubuntu-location-service-doc,
56Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
57 libdbus-1-dev,
58 libdbus-cpp-dev,
59 libboost-dev,
60 ${misc:Depends},
61Suggests: ubuntu-location-service-doc,
62Description: location service aggregating position/velocity/heading
63 updates and exporting them over dbus.
64 .
65 Contains header files required to develop clients talking to the ubuntu
66 location service.
67
68Package: libubuntu-location-service-dbg
69Section: debug
70Architecture: any
71Multi-Arch: foreign
72Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
73 ${misc:Depends},
74Description: location service aggregating position/velocity/heading
75 updates and exporting them over dbus.
76 .
77 Contains debug symbols.
78
79Package: ubuntu-location-service-tests
80Architecture: any
81Depends: ${misc:Depends},
82 ${shlibs:Depends},
83Description: location service aggregating position/velocity/heading
84 updates and exporting them over dbus.
85 .
86 Contains all test executables
87
88Package: ubuntu-location-service-bin
89Architecture: any
90Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
91 ${misc:Depends},
92 ${shlibs:Depends},
93 trust-store-bin,
94Breaks: ubuntu-location-service-examples (<< 0.0.2),
95Replaces: ubuntu-location-service-examples (<< 0.0.2),
96Description: location service aggregating position/velocity/heading
97 updates and exporting them over dbus.
98 .
99 Contains the service executable and man pages.
100
101Package: ubuntu-location-service-examples
102Architecture: any
103Multi-Arch: same
104Depends: libubuntu-location-service@UBUNTU_LOCATION_SERVICE_SOVERSION@ (= ${binary:Version}),
105 ${misc:Depends},
106 ${shlibs:Depends},
107 ubuntu-location-service-doc,
108Description: location service aggregating position/velocity/heading
109 updates and exporting them over dbus.
110 .
111 Contains example service and client.
112
113Package: ubuntu-location-service-doc
114Section: doc
115Architecture: all
116Multi-Arch: foreign
117Depends: ${misc:Depends},
118 ${shlibs:Depends},
119Recommends: ubuntu-location-service-examples,
120Description: location service aggregating position/velocity/heading
121 updates and exporting them over dbus.
122 .
123 Contains documentation for service and client.
0124
=== added file 'debian/gen-debian-files.sh'
--- debian/gen-debian-files.sh 1970-01-01 00:00:00 +0000
+++ debian/gen-debian-files.sh 2016-01-18 13:07:31 +0000
@@ -0,0 +1,111 @@
1#!/bin/sh
2
3# Copyright (C) 2015 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Michi Henning <michi.henning@canonical.com>
18# Thomas Voß <thomas.voss@canonical.com>
19
20#
21# Script to generate debian files for dual landing in Vivid (gcc 4.9 ABI)
22# and Wily and later (gcc 5 ABI).
23#
24# This script is called from debian/rules and generates:
25#
26# - control
27# - libubuntu-location-service${soversion}.install.${target_arch}
28#
29# For all but control, this is a straight substition and/or renaming exercise for each file.
30# For control, if building on Wily or later, we also fix the "Replaces:" and "Conflicts:"
31# entries, so we don't end up with two packages claiming ownership of the same places
32# in the file system.
33#
34# Because the debian files for the different distributions are generated on the fly,
35# this allows us to keep a single source tree for both distributions. See ../HACKING
36# for more explanations.
37#
38
39set -e # Fail if any command fails.
40
41progname=$(basename $0)
42
43[ $# -ne 1 ] && {
44 echo "usage: $progname path-to-debian-dir" >&2
45 exit 1
46}
47dir=$1
48version_dir=$(mktemp -d)
49
50# Dump version numbers into files and initialize vars from those files.
51
52sh ${dir}/get-versions.sh ${dir} ${version_dir}
53
54full_version=$(cat "${version_dir}"/libubuntu-location-service.full-version)
55major_minor=$(cat "${version_dir}"/libubuntu-location-service.major-minor-version)
56soversion=$(cat "${version_dir}"/libubuntu-location-service.soversion)
57vivid_soversion=$(cat "${version_dir}"/libubuntu-location-service.vivid-soversion)
58
59warning=$(mktemp -t gen-debian-files-msg.XXX)
60
61trap "rm -fr $warning $version_dir" 0 INT TERM QUIT
62
63warning_msg()
64{
65 cat >$warning <<EOF
66# This file is autogenerated. DO NOT EDIT!
67#
68# Modifications should be made to $(basename "$1") instead.
69# This file is regenerated automatically in the clean target.
70#
71EOF
72}
73
74# Generate debian/control from debian/control.in, substituting the soversion for both libs.
75# For wily onwards, we also add an entry for the vivid versions to "Conflicts:" and "Replaces:".
76
77infile="${dir}"/control.in
78outfile="${dir}"/control
79warning_msg $infile
80cat $warning $infile \
81 | sed -e "s/@UBUNTU_LOCATION_SERVICE_SOVERSION@/${soversion}/" > "$outfile"
82
83[ "$distro" != "vivid" ] && {
84 sed -i -e "/Replaces: libubuntu-location-service2,/a\
85\ libubuntu-location-service${vivid_soversion}," \
86 "$outfile"
87}
88
89# Generate the install files, naming them according to the soversion.
90
91# Install file for binary package
92infile="${dir}"/libubuntu-location-service.install.in
93outfile="${dir}"/libubuntu-location-service${soversion}.install
94warning_msg "$infile"
95cat $warning "$infile" >"$outfile"
96
97infile="${dir}"/libubuntu-location-service.install.with-gps.in
98outfile="${dir}"/libubuntu-location-service${soversion}.install.with-gps
99warning_msg "$infile"
100cat $warning "$infile" >"$outfile"
101
102infile="${dir}"/libubuntu-location-service-dev.install.in
103outfile="${dir}"/libubuntu-location-service-dev.install
104warning_msg "$infile"
105cat $warning $infile | sed -e "s/@UBUNTU_LOCATION_SERVICE_SOVERSION@/${soversion}/" > "$outfile"
106
107ln -s "${dir}"/libubuntu-location-service${soversion}.install.with-gps "${dir}"/libubuntu-location-service${soversion}.install.amd64
108ln -s "${dir}"/libubuntu-location-service${soversion}.install.with-gps "${dir}"/libubuntu-location-service${soversion}.install.armhf
109ln -s "${dir}"/libubuntu-location-service${soversion}.install.with-gps "${dir}"/libubuntu-location-service${soversion}.install.i386
110
111exit 0
0112
=== added file 'debian/get-versions.sh'
--- debian/get-versions.sh 1970-01-01 00:00:00 +0000
+++ debian/get-versions.sh 2016-01-18 13:07:31 +0000
@@ -0,0 +1,68 @@
1#!/bin/sh
2
3# Copyright (C) 2015 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Michi Henning <michi.henning@canonical.com>
18
19#
20# Script to read the version numbers from VERSION and QT-VERSION
21# and write the version components and the soversion numbers
22# into separate files, so we can pick them up from both
23# gen-debian-files.sh and CMakeLists.txt.
24#
25
26set -e # Fail if any command fails.
27
28progname=$(basename $0)
29
30[ $# -lt 1 -o $# -gt 2 ] && {
31 echo "usage: $progname path-to-debian-dir [output-dir]" >&2
32 exit 1
33}
34dir=$1
35output_dir=`pwd`
36[ $# -eq 2 ] && output_dir=$2
37
38# Write the various version numbers into a bunch of files. This allows
39# us to easily pick them up from both gen-debian-files.sh and CMakeLists.txt.
40
41distro=$(lsb_release -c -s)
42
43full_version=$(cat "${dir}"/VERSION)
44
45major=$(echo $full_version | cut -d'.' -f1)
46minor=$(echo $full_version | cut -d'.' -f2)
47micro=$(echo $full_version | cut -d'.' -f3)
48major_minor="${major}.${minor}"
49
50vivid_full_version=$(cat "${dir}"/VERSION.vivid)
51vivid_major=$(echo $vivid_full_version | cut -d'.' -f1)
52vivid_soversion=$vivid_major
53
54if [ "$distro" = "vivid" ]
55then
56 soversion=${vivid_soversion}
57else
58 soversion="${major}"
59fi
60[ -n $soversion ]
61
62echo ${full_version} >${output_dir}/libubuntu-location-service.full-version
63echo ${major} >${output_dir}/libubuntu-location-service.major-version
64echo ${minor} >${output_dir}/libubuntu-location-service.minor-version
65echo ${micro} >${output_dir}/libubuntu-location-service.micro-version
66echo ${major_minor} >${output_dir}/libubuntu-location-service.major-minor-version
67echo ${soversion} >${output_dir}/libubuntu-location-service.soversion
68echo ${vivid_soversion} >${output_dir}/libubuntu-location-service.vivid-soversion
069
=== removed file 'debian/libubuntu-location-service-dev.install'
--- debian/libubuntu-location-service-dev.install 2014-07-18 14:42:10 +0000
+++ debian/libubuntu-location-service-dev.install 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1usr/include/ubuntu-location-service-2
2usr/lib/*/libubuntu-location-service.so
3usr/lib/*/libubuntu-location-service-connectivity.so
4usr/lib/*/pkgconfig/ubuntu-location-service.pc
5usr/lib/*/pkgconfig/ubuntu-location-service-connectivity.pc
60
=== added file 'debian/libubuntu-location-service-dev.install.in'
--- debian/libubuntu-location-service-dev.install.in 1970-01-01 00:00:00 +0000
+++ debian/libubuntu-location-service-dev.install.in 2016-01-18 13:07:31 +0000
@@ -0,0 +1,5 @@
1usr/include/ubuntu-location-service-@UBUNTU_LOCATION_SERVICE_SOVERSION@
2usr/lib/*/libubuntu-location-service.so
3usr/lib/*/libubuntu-location-service-connectivity.so
4usr/lib/*/pkgconfig/ubuntu-location-service.pc
5usr/lib/*/pkgconfig/ubuntu-location-service-connectivity.pc
06
=== added file 'debian/libubuntu-location-service.install.in'
--- debian/libubuntu-location-service.install.in 1970-01-01 00:00:00 +0000
+++ debian/libubuntu-location-service.install.in 2016-01-18 13:07:31 +0000
@@ -0,0 +1,2 @@
1usr/lib/*/libubuntu-location-service.so.*
2usr/lib/*/libubuntu-location-service-connectivity.so.*
03
=== added file 'debian/libubuntu-location-service.install.with-gps.in'
--- debian/libubuntu-location-service.install.with-gps.in 1970-01-01 00:00:00 +0000
+++ debian/libubuntu-location-service.install.with-gps.in 2016-01-18 13:07:31 +0000
@@ -0,0 +1,3 @@
1usr/lib/*/libubuntu-location-service.so.*
2usr/lib/*/libubuntu-location-service-connectivity.so.*
3/etc/gps.conf
04
=== removed file 'debian/libubuntu-location-service2.install'
--- debian/libubuntu-location-service2.install 2014-07-30 13:55:44 +0000
+++ debian/libubuntu-location-service2.install 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1usr/lib/*/libubuntu-location-service.so.*
2usr/lib/*/libubuntu-location-service-connectivity.so.*
30
=== removed symlink 'debian/libubuntu-location-service2.install.amd64'
=== target was u'libubuntu-location-service2.install.with-gps'
=== removed symlink 'debian/libubuntu-location-service2.install.armhf'
=== target was u'libubuntu-location-service2.install.with-gps'
=== removed symlink 'debian/libubuntu-location-service2.install.i386'
=== target was u'libubuntu-location-service2.install.with-gps'
=== removed file 'debian/libubuntu-location-service2.install.with-gps'
--- debian/libubuntu-location-service2.install.with-gps 2014-07-30 13:55:44 +0000
+++ debian/libubuntu-location-service2.install.with-gps 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1usr/lib/*/libubuntu-location-service.so.*
2usr/lib/*/libubuntu-location-service-connectivity.so.*
3/etc/gps.conf
40
=== modified file 'debian/rules'
--- debian/rules 2015-07-15 19:04:43 +0000
+++ debian/rules 2016-01-18 13:07:31 +0000
@@ -15,6 +15,18 @@
1515
16include /usr/share/dpkg/default.mk16include /usr/share/dpkg/default.mk
1717
18distro=$(shell lsb_release -c -s)
19
20ifeq ($(distro),vivid)
21 full_version=$(shell cat $(CURDIR)/debian/VERSION.vivid)
22else
23 full_version=$(shell cat $(CURDIR)/debian/VERSION)
24endif
25
26major=$(shell echo $(full_version) | cut -d'.' -f1)
27minor=$(shell echo $(full_version) | cut -d'.' -f2)
28patch=$(shell echo $(full_version) | cut -d'.' -f3)
29
18ifneq (,$(filter $(DEB_HOST_ARCH),ppc64el powerpc arm64))30ifneq (,$(filter $(DEB_HOST_ARCH),ppc64el powerpc arm64))
19 LOCATION_SERVICE_ENABLE_GPS_PROVIDER = OFF31 LOCATION_SERVICE_ENABLE_GPS_PROVIDER = OFF
20else32else
@@ -31,4 +43,11 @@
31 dh_strip --dbg-package=libubuntu-location-service-dbg43 dh_strip --dbg-package=libubuntu-location-service-dbg
3244
33override_dh_auto_configure:45override_dh_auto_configure:
34 dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/ubuntu-location-service -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=$(LOCATION_SERVICE_ENABLE_GPS_PROVIDER)46 dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/ubuntu-location-service -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=$(LOCATION_SERVICE_ENABLE_GPS_PROVIDER) -DUBUNTU_LOCATION_SERVICE_VERSION_MAJOR=$(major) -DUBUNTU_LOCATION_SERVICE_VERSION_MINOR=$(minor) -DUBUNTU_LOCATION_SERVICE_VERSION_PATCH=$(patch)
47
48override_dh_auto_clean:
49 rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.amd64
50 rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.armhf
51 rm -f $(CURDIR)/debian/libubuntu-location-service$(major).install.i386
52 /bin/sh $(CURDIR)/debian/gen-debian-files.sh $(CURDIR)/debian
53 dh_auto_clean
3554
=== modified file 'debian/source/format'
--- debian/source/format 2014-07-30 14:15:06 +0000
+++ debian/source/format 2016-01-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +0000 differ148Binary files doc/images/LocationServiceHighLevel.png 1970-01-01 00:00:00 +0000 and doc/images/LocationServiceHighLevel.png 2016-01-18 13:07:31 +0000 differ
=== added file 'doc/intro.md'
--- doc/intro.md 1970-01-01 00:00:00 +0000
+++ doc/intro.md 2016-01-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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 '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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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/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-18 13:07:31 +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-18 13:07:31 +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/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-18 13:07:31 +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,6 +181,8 @@
175 trap->stop();181 trap->stop();
176 });182 });
177183
184 auto runtime = location::service::Runtime::create();
185
178 const location::Configuration empty_provider_configuration;186 const location::Configuration empty_provider_configuration;
179187
180 std::set<location::Provider::Ptr> instantiated_providers;188 std::set<location::Provider::Ptr> instantiated_providers;
@@ -201,8 +209,10 @@
201 }209 }
202 }210 }
203211
204 config.incoming->install_executor(dbus::asio::make_executor(config.incoming));212 config.incoming->install_executor(dbus::asio::make_executor(config.incoming, runtime->service()));
205 config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing));213 config.outgoing->install_executor(dbus::asio::make_executor(config.outgoing, runtime->service()));
214
215 runtime->start();
206216
207 location::service::DefaultConfiguration dc;217 location::service::DefaultConfiguration dc;
208218
@@ -214,77 +224,15 @@
214 dc.the_permission_manager(config.outgoing),224 dc.the_permission_manager(config.outgoing),
215 location::service::Harvester::Configuration225 location::service::Harvester::Configuration
216 {226 {
217 location::connectivity::platform_default_manager(),227 std::make_shared<dummy::ConnectivityManager>(),
218 // We submit location/wifi/cell measurements to both228 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 }229 }
241 };230 };
242231
243 auto location_service = std::make_shared<location::service::Implementation>(configuration);232 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};
270233
271 trap->run();234 trap->run();
272235
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;236 return EXIT_SUCCESS;
289}237}
290238
291239
=== 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-18 13:07:31 +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,21 @@
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 =
160 configuration.engine->updates.last_known_location.get();
161 if (last_known_position &&
162 status == culs::session::Interface::Updates::Status::enabled)
163 {
164 // Immediately send the last known position to the client
165 if (auto session_iface = session_weak.lock())
166 {
167 session_iface->updates().position = last_known_position.get();
168 }
169 }
170 });
171 return session_iface;
153}172}
154173
=== 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-18 13:07:31 +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(1);
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-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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/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-18 13:07:31 +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-18 13:07:31 +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)
9899
=== modified file 'tests/acceptance_tests.cpp'
--- tests/acceptance_tests.cpp 2015-02-13 13:19:18 +0000
+++ tests/acceptance_tests.cpp 2016-01-18 13:07:31 +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,11 +814,11 @@
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.",
715 std::uint32_t{50});821 std::uint32_t{10});
716822
717 options.add(Keys::test_duration,823 options.add(Keys::test_duration,
718 "Test duration in [s]",824 "Test duration in [s]",
@@ -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
=== modified file 'tests/engine_test.cpp'
--- tests/engine_test.cpp 2015-01-21 20:04:56 +0000
+++ tests/engine_test.cpp 2016-01-18 13:07:31 +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-18 13:07:31 +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
=== modified file 'tests/position_test.cpp'
--- tests/position_test.cpp 2014-06-20 07:40:34 +0000
+++ tests/position_test.cpp 2016-01-18 13:07:31 +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
=== added file 'tests/runtime_test.cpp'
--- tests/runtime_test.cpp 1970-01-01 00:00:00 +0000
+++ tests/runtime_test.cpp 2016-01-18 13:07:31 +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-18 13:07:31 +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-18 13:07:31 +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