Merge lp:~thomas-voss/location-service/adjust-default-timeout-for-gps-xtra-download into lp:location-service/trunk

Proposed by Thomas Voß
Status: Superseded
Proposed branch: lp:~thomas-voss/location-service/adjust-default-timeout-for-gps-xtra-download
Merge into: lp:location-service/trunk
Diff against target: 1118 lines (+885/-34) (has conflicts)
18 files modified
CMakeLists.txt (+14/-0)
_clang-format (+56/-0)
astyle-config (+43/-0)
debian/changelog (+32/-0)
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/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 (+4/-23)
src/location_service/com/ubuntu/location/service/session/skeleton.cpp (+21/-3)
tests/gps_provider_test.cpp (+83/-0)
tools/CMakeLists.txt (+1/-0)
tools/symbol_diff.in (+70/-0)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~thomas-voss/location-service/adjust-default-timeout-for-gps-xtra-download
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+277425@code.launchpad.net

This proposal has been superseded by a proposal from 2015-11-13.

Commit message

Adjust default timeout for downloading GPS XTRA data.

30 seconds are perfectly fine, as operation without the xtra data
will take significantly longer.

Description of the change

Adjust default timeout for downloading GPS XTRA data.

30 seconds are perfectly fine, as operation without the xtra data
will take significantly longer.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-09-18 23:06:08 +0000
3+++ CMakeLists.txt 2015-11-13 10:22:15 +0000
4@@ -54,6 +54,20 @@
5 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
6 endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
7
8+#
9+# Code style fixer. We rely on clang-format to adjust the formatting of source code.
10+#
11+find_program(CLANG_FORMAT_COMMAND NAMES clang-format-3.6 clang-format-3.5)
12+if (NOT CLANG_FORMAT_COMMAND)
13+ message(WARNING "Cannot find clang-format >= clang-format-3.5: formatcode target will not be available")
14+endif()
15+
16+if (CLANG_FORMAT_COMMAND)
17+ file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES ${CMAKE_SOURCE_DIR}/include/*.h)
18+ file(GLOB_RECURSE UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES ${CMAKE_SOURCE_DIR}/src/*.h ${CMAKE_SOURCE_DIR}/src/*.cpp)
19+ add_custom_target(formatcode ${CLANG_FORMAT_COMMAND} -i ${UBUNTU_LOCATION_SERVICE_INTERFACE_HEADER_FILES} ${UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_FILES} SOURCES _clang-format)
20+endif()
21+
22 include_directories(
23 ${Boost_INCLUDE_DIRS}
24 ${DBUS_INCLUDE_DIRS}
25
26=== added file '_clang-format'
27--- _clang-format 1970-01-01 00:00:00 +0000
28+++ _clang-format 2015-11-13 10:22:15 +0000
29@@ -0,0 +1,56 @@
30+---
31+Language: Cpp
32+AccessModifierOffset: -4
33+ConstructorInitializerIndentWidth: 4
34+AlignEscapedNewlinesLeft: false
35+AlignTrailingComments: true
36+AllowAllParametersOfDeclarationOnNextLine: true
37+AllowShortBlocksOnASingleLine: false
38+AllowShortIfStatementsOnASingleLine: false
39+AllowShortLoopsOnASingleLine: false
40+AllowShortFunctionsOnASingleLine: All
41+AlwaysBreakTemplateDeclarations: false
42+AlwaysBreakBeforeMultilineStrings: false
43+BreakBeforeBinaryOperators: false
44+BreakBeforeTernaryOperators: true
45+BreakConstructorInitializersBeforeComma: false
46+BinPackParameters: true
47+ColumnLimit: 0
48+ConstructorInitializerAllOnOneLineOrOnePerLine: false
49+DerivePointerAlignment: false
50+ExperimentalAutoDetectBinPacking: false
51+IndentCaseLabels: false
52+IndentWrappedFunctionNames: false
53+IndentFunctionDeclarationAfterType: false
54+MaxEmptyLinesToKeep: 1
55+KeepEmptyLinesAtTheStartOfBlocks: true
56+NamespaceIndentation: None
57+ObjCSpaceAfterProperty: false
58+ObjCSpaceBeforeProtocolList: true
59+PenaltyBreakBeforeFirstCallParameter: 19
60+PenaltyBreakComment: 300
61+PenaltyBreakString: 1000
62+PenaltyBreakFirstLessLess: 120
63+PenaltyExcessCharacter: 1000000
64+PenaltyReturnTypeOnItsOwnLine: 60
65+PointerAlignment: Left
66+SpacesBeforeTrailingComments: 1
67+Cpp11BracedListStyle: true
68+Standard: Cpp11
69+IndentWidth: 4
70+TabWidth: 8
71+UseTab: Never
72+BreakBeforeBraces: Allman
73+SpacesInParentheses: false
74+SpacesInAngles: false
75+SpaceInEmptyParentheses: false
76+SpacesInCStyleCastParentheses: false
77+SpacesInContainerLiterals: true
78+SpaceBeforeAssignmentOperators: true
79+ContinuationIndentWidth: 4
80+CommentPragmas: '^ IWYU pragma:'
81+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
82+SpaceBeforeParens: ControlStatements
83+DisableFormat: false
84+...
85+
86
87=== added file 'astyle-config'
88--- astyle-config 1970-01-01 00:00:00 +0000
89+++ astyle-config 2015-11-13 10:22:15 +0000
90@@ -0,0 +1,43 @@
91+# Options for formatting code with astyle.
92+#
93+# This helps to make code match the style guide.
94+#
95+# Use like this:
96+#
97+# astyle --options=astyle-config mfile.h myfile.cpp
98+#
99+# Occasionally, astyle does something silly (particularly with lambdas), so it's
100+# still necessary to scan the changes for things that are wrong.
101+# But, for most files, it does a good job.
102+#
103+# Please consider using this before checking code in for review. Code reviews shouldn't
104+# have to deal with layout issues, they are just a distraction. It's better to be able
105+# to focus on semantics in a code review, with style issues out of the way.
106+
107+--formatted
108+--style=allman
109+--min-conditional-indent=2
110+--indent-switches
111+--max-instatement-indent=120
112+--pad-header
113+--align-pointer=type
114+--align-reference=type
115+--convert-tabs
116+--close-templates
117+--max-code-length=120
118+
119+# --pad-oper
120+#
121+# Commented out for now. It changes
122+#
123+# for (int i=0; i<10; ++i)
124+# to
125+# for (int i = 0; i < 10; ++i)
126+#
127+# Unfortunately, it also messes with rvalue references:
128+#
129+# ResourcePtr& operator=(ResourcePtr&& r);
130+#
131+# becomes:
132+#
133+# ResourcePtr& operator=(ResourcePtr && r);
134
135=== modified file 'debian/changelog'
136--- debian/changelog 2015-07-27 18:07:37 +0000
137+++ debian/changelog 2015-11-13 10:22:15 +0000
138@@ -1,3 +1,4 @@
139+<<<<<<< TREE
140 location-service (2.1+15.10.20150727-0ubuntu1) wily; urgency=medium
141
142 [ CI Train Bot ]
143@@ -36,6 +37,37 @@
144
145 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 28 May 2015 11:40:58 +0000
146
147+=======
148+location-service (2.1+15.04.20151109.2-0ubuntu1) vivid; urgency=medium
149+
150+ [ Alberto Mardegan ]
151+ * Make sure that injected time is given in milliseconds
152+
153+ [ Thomas Voß ]
154+ * Cherry-pick rev. 196 and 199 from lp:location-service. The changes
155+ got accidentally removed by merging the outstanding documentation
156+ branch.
157+ * Handle responses of clients to updates asynchronously. Rely on
158+ dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
159+ #1462664, #1387643)
160+
161+ -- David Barth <david.barth@canonical.com> Mon, 09 Nov 2015 20:48:48 +0000
162+
163+location-service (2.1+15.04.20151022-0ubuntu1) vivid; urgency=medium
164+
165+ [ Thomas Voß ]
166+ * Add documentation for debugging, hacking and debugging the location
167+ service. Pull manual testing instructions over from the wiki. Add
168+ tools for formatting the source.
169+
170+ [ thomas-voss ]
171+ * Add documentation for debugging, hacking and debugging the location
172+ service. Pull manual testing instructions over from the wiki. Add
173+ tools for formatting the source.
174+
175+ -- Thomas Voß <ci-train-bot@canonical.com> Thu, 22 Oct 2015 07:16:50 +0000
176+
177+>>>>>>> MERGE-SOURCE
178 location-service (2.1+15.04.20150427.1-0ubuntu1) vivid; urgency=medium
179
180 [ CI Train Bot ]
181
182=== modified file 'doc/Doxyfile.in'
183--- doc/Doxyfile.in 2014-05-19 09:55:25 +0000
184+++ doc/Doxyfile.in 2015-11-13 10:22:15 +0000
185@@ -748,7 +748,7 @@
186 # directories that contain image that are included in the documentation (see
187 # the \image command).
188
189-IMAGE_PATH =
190+IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images
191
192 # The INPUT_FILTER tag can be used to specify a program that doxygen should
193 # invoke to filter for each input file. Doxygen will invoke the filter program
194@@ -1463,7 +1463,7 @@
195 # generate an XML file that captures the structure of
196 # the code including all documentation.
197
198-GENERATE_XML = NO
199+GENERATE_XML = YES
200
201 # The XML_OUTPUT tag is used to specify where the XML pages will be put.
202 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
203
204=== added file 'doc/daemon_and_cli.md'
205--- doc/daemon_and_cli.md 1970-01-01 00:00:00 +0000
206+++ doc/daemon_and_cli.md 2015-11-13 10:22:15 +0000
207@@ -0,0 +1,55 @@
208+# Service Daemon and CLI
209+
210+The location service offers a daemon executable and a corresponding
211+command-line interface for interacting with it. The daemon does not
212+necessarily require root privileges, but might so depending on your
213+configuration.
214+
215+Run the following command to receive an overview of the arguments to
216+the daemon:
217+
218+ ubuntu-location-serviced --help
219+
220+An example invocation of the daemon, configuring a GPS provider that
221+relies on the Android HAL to talk to the chipset, exposing the service
222+on the system DBus instance:
223+
224+ ubuntu-location-serviced --bus system --provider gps::Provider
225+
226+The cli allows for querying properties of a running service instance, e.g.:
227+
228+ ubuntu-location-serviced-cli --bus system --get --property is_online
229+
230+## Configuring an Out-Of-Process Provider
231+
232+If you want to run a provider out of process, the daemon executable
233+allows you to do so by instantiating a so-called remote provider. The
234+following invocation of the service tries to connect to the provider
235+instance described by the given unique DBus name and path.
236+
237+ ubuntu-location-serviced \
238+ --bus system \
239+ --provider remote::Provider \
240+ --remote::Provider::bus=system \
241+ --remote::Provider::name=com.ubuntu.location.provider.Gps \
242+ --remote::Provider::path=/
243+
244+Please note that the service allows for decorating provider names to
245+uniquely identify per provider configuration options and to allow for
246+loading more than one provider of a certain kind. The following
247+configuration configures two remote providers, one relying on GPS
248+(decorated with @gps) and another one relying on network-based
249+positioning (decorated with @network):
250+
251+ ubuntu-location-serviced \
252+ --bus system \
253+ --provider remote::Provider@gps \
254+ --remote::Provider@gps::bus=system \
255+ --remote::Provider@gps::name=com.ubuntu.location.provider.Gps \
256+ --remote::Provider@gps::path=/ \
257+ --provider remote::Provider@network \
258+ --remote::Provider@network::bus=system \
259+ --remote::Provider@network::name=com.ubuntu.location.provider.Network \
260+ --remote::Provider@network::path=/
261+
262+
263
264=== added file 'doc/debugging.md'
265--- doc/debugging.md 1970-01-01 00:00:00 +0000
266+++ doc/debugging.md 2015-11-13 10:22:15 +0000
267@@ -0,0 +1,92 @@
268+# Debugging
269+
270+Location not working? Here's how to debug.
271+
272+## Layers
273+
274+Test in OSMTouch (QML app using Qt API) before testing in webapps or
275+webbrowser app. Different results? File a bug where it doesn't
276+work. Same result of no location? Next step.
277+
278+## Check that stack works with dummy provider
279+
280+Edit /etc/init/ubuntu-location-provider.override to start
281+location-serviced with just the dummy provider; this should
282+work. Doesn't work? File a bug against location-service. Works? Reset
283+config to defaults and try the next thing.
284+
285+## Hardware GPS breaking all of location-service
286+
287+GPS provider is built-in into location-service and might break all of
288+it if it goes south (working on splitting it out); try enabling only
289+the HERE provider on the location-serviced command-line and see if
290+that works. Works? File a bug against location-service. Doesn't work?
291+Move on.
292+
293+## HERE test
294+
295+To test whether the low-level HERE stack gets a location, put
296+http://people.canonical.com/~lool/espoo-cli on your phone (will be
297+included along HERE bits in the future) and run with:
298+
299+ chmod a+x espoo-cli
300+ GLOG_logtostderr=1 GLOG_v=100 LD_LIBRARY_PATH=/custom/vendor/here/location-provider/lib/arm-linux-gnueabihf ./espoo-cli 5
301+
302+NB: 5 is the number of location updates after which the tool exits;
303+updates should come in at approx 15s interval. Output looks like:
304+
305+ I1101 21:30:01.285964 4403 cli.cpp:117] Requested number of updates is 2
306+ I1101 21:30:01.299002 4403 cli.cpp:133] Starting location updates
307+ I1101 21:30:01.301888 4403 cli.cpp:141] Starting GLib main loop
308+ 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
309+ I1101 21:30:11.306061 4403 cli.cpp:170] Remaining updates: 1
310+ 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
311+ I1101 21:30:26.738348 4403 cli.cpp:148] Stopping location updates
312+
313+Low-level HERE stack works but location-serviced with just HERE
314+provider doesn't work? File a bug against espoo projet (HERE) and/or
315+location-service. Low-level HERE stack doesn't work? Move on
316+
317+## location-service and espoo-service debug
318+
319+Collect some debug data by editing /etc/init/ubuntu-espoo-service.conf
320+and /etc/init/ubuntu-location-service.override and changing the start
321+sequence to add some env vars:
322+
323+ export GLOG_v=200
324+ export GLOG_logtostderr=1
325+
326+before the exec. Reboot, and start some app. You should have some log
327+files under /var/log/upstart/ubuntu-espoo-service.log and
328+/var/log/upstart/ubuntu-location-service.log to attach to a bug
329+report; e.g. a working espoo log looks like this:
330+
331+ WARNING: Logging before InitGoogleLogging() is written to STDERR
332+ I1105 16:30:10.221474 1620 provider.cpp:568] StartPositionUpdates
333+ I1105 16:30:10.224901 1620 provider.cpp:122] Successfully started position updates.
334+ I1105 16:30:10.228739 1620 provider.cpp:596] StartVelocityUpdates
335+ 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)
336+
337+No position there? check connectivity API works by running:
338+
339+ cd /tmp
340+ wget http://people.ubuntu.com/~lool/connectivity
341+ GLOG_v=200 GLOG_logtostderr=1 ./connectivity
342+
343+you should see something like:
344+
345+ I1105 16:47:26.431466 11140 cached_radio_cell.cpp:160] (mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
346+ I1105 16:47:26.533818 11140 connectivity.cpp:47] Is wifi enabled: true
347+ I1105 16:47:26.533963 11140 connectivity.cpp:48] Is wifi hw enabled: true
348+ I1105 16:47:26.534010 11140 connectivity.cpp:49] Is wwan enabled: true
349+ I1105 16:47:26.534050 11140 connectivity.cpp:50] Is wwan hw enabled: true
350+ I1105 16:47:26.534442 11140 connectivity.cpp:122] umts(mcc: 123, mnc: 2, lac: 1234, id: 123456, asu: 1)
351+ 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)
352+ 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)
353+
354+Also, please attach output of /usr/share/ofono/scripts/list-modems > list-modems-output.txt
355+Please note that the command might take ~1 minute to complete.
356+
357+TODO: document dbus-monitor / d-feet capturing of client / system traffic with snooping config.
358+
359+
360
361=== added file 'doc/hacking.md'
362--- doc/hacking.md 1970-01-01 00:00:00 +0000
363+++ doc/hacking.md 2015-11-13 10:22:15 +0000
364@@ -0,0 +1,146 @@
365+# Hacking
366+
367+
368+## Building the code
369+
370+By default, the code is built in release mode. To build a debug version, use
371+
372+ $ mkdir builddebug
373+ $ cd builddebug
374+ $ cmake -DCMAKE_BUILD_TYPE=debug ..
375+ $ make
376+
377+For a release version, use -DCMAKE_BUILD_TYPE=release
378+
379+## Running the tests
380+
381+ $ make
382+ $ make test
383+
384+Note that "make test" alone is dangerous because it does not rebuild
385+any tests if either the library or the test files themselves need
386+rebuilding. It's not possible to fix this with cmake because cmake cannot
387+add build dependencies to built-in targets. To make sure that everything
388+is up-to-date, run "make" before running "make test"!
389+
390+## Coverage
391+
392+To build with the flags for coverage testing enabled and get coverage:
393+
394+ $ mkdir buildcoverage
395+ $ cd buildcoverage
396+ $ cmake -DCMAKE_BUILD_TYPE=coverage
397+ $ make
398+ $ make test
399+ $ make coverage
400+
401+Unfortunately, it is not possible to get 100% coverage for some files,
402+mainly due to gcc's generation of two destructors for dynamic and non-
403+dynamic instances. For abstract base classes and for classes that
404+prevent stack and static allocation, this causes one of the destructors
405+to be reported as uncovered.
406+
407+There are also issues with some functions in header files that are
408+incorrectly reported as uncovered due to inlining, as well as
409+the impossibility of covering defensive assert(false) statements,
410+such as an assert in the default branch of a switch, where the
411+switch is meant to handle all possible cases explicitly.
412+
413+If you run a binary and get lots of warnings about a "merge mismatch for summaries",
414+this is caused by having made changes to the source that add or remove code
415+that was previously run, so the new coverage output cannot sensibly be merged
416+into the old coverage output. You can get rid of this problem by running
417+
418+ $ make clean-coverage
419+
420+This deletes all the .gcda files, allowing the merge to (sometimes) succeed again.
421+If this doesn't work either, the only remedy is to do a clean build.
422+
423+If lcov complains about unrecognized lines involving '=====',
424+you can patch geninfo and gcovr as explained here:
425+
426+https://bugs.launchpad.net/gcovr/+bug/1086695/comments/2
427+
428+## Code style
429+
430+We use a format tool that fixes a whole lot of issues
431+regarding code style. The formatting changes made by
432+the tool are generally sensible (even though they may not be your
433+personal preference in all cases). If there is a case where the formatting
434+really messes things up, consider re-arranging the code to avoid the problem.
435+The convenience of running the entire code base through the pretty-printer
436+far outweighs any minor glitches with pretty printing, and it means that
437+we get consistent code style for free, rather than endlessly having to
438+watch out for formatting issues during code reviews.
439+
440+As of clang-format-3.7, you can use
441+
442+ // clang-format off
443+ void unformatted_code ;
444+ // clang-format on
445+
446+to suppress formatting for a section of code.
447+
448+To format specific files:
449+
450+ ${CMAKE_BINARY_DIR}/tools/formatcode x.cpp x.h
451+
452+If no arguments are provided, formatcode reads stdin and writes
453+stdout, so you can easily pipe code into the tool from within an
454+editor. For example, to reformat the entire file in vi (assuming
455+${CMAKE_BINARY_DIR}/tools is in your PATH):
456+
457+ 1G!Gformatcode
458+
459+To re-format all source and header files in the tree:
460+
461+ $ make formatcode
462+
463+## Thread and address sanitizer
464+
465+Set SANITIZER to "thread" or "address" to build with the
466+corresponding sanitizer enabled.
467+
468+## Updating symbols file
469+
470+To easily spot new/removed/changed symbols in the library, the debian
471+package maintains a .symbols file that lists all exported symbols
472+present in the library .so. If you add new public symbols to the library,
473+it's necessary to refresh the symbols file, otherwise the package will
474+fail to build. The easiest way to do that is using bzr-builddeb:
475+
476+ $ bzr bd -- -us -uc -j8 # Don't sign source package or changes file, 8 compiles in parallel
477+ $ # this will exit with an error if symbols file isn't up-to-date
478+ $ cd ../build-area/location-service-[version]
479+ $ ./obj-[arch]/tools/symbol_diff
480+
481+This creates a diff of the symbols in /tmp/symbols.diff.
482+(The demangled symbols from the debian build are in ./new_symbols.)
483+
484+Review any changes in /tmp/symbols.diff. If they are OK:
485+
486+ $ cd -
487+ $ patch -p0 < /tmp/symbols.diff
488+
489+## ABI compliance test
490+
491+To use this, install abi-compliance-checker package from the archives.
492+
493+You can use abi-compliance-checker to test whether a particular build
494+is ABI compatible with another build. The tool does some source-level
495+analysis in addition to checking library symbols, so it catches things
496+that are potentially dangerous, but won't be picked up by just looking
497+at the symbol table.
498+
499+Assume you have built devel in src/devel, and you have a later build
500+in src/mybranch and want to check that mybranch is still compatible.
501+To run the compliance test:
502+
503+ $ cd src
504+ $ abi-compliance-checker -lib libunity-scopes.so -old devel/build/test/abi-compliance/abi.xml -new mybranch/build/test/abi-compliance/abi.xml
505+
506+The script will take about two minutes to run. Now point your browser at
507+
508+ src/compat_reports/libunity-scopes.so/[version]_to_[version]/compat_report.html
509+
510+The report provides a nicely layed-out page with all the details.
511
512=== added directory 'doc/images'
513=== added file 'doc/images/LocationServiceHighLevel.png'
514Binary files doc/images/LocationServiceHighLevel.png 1970-01-01 00:00:00 +0000 and doc/images/LocationServiceHighLevel.png 2015-11-13 10:22:15 +0000 differ
515=== added file 'doc/intro.md'
516--- doc/intro.md 1970-01-01 00:00:00 +0000
517+++ doc/intro.md 2015-11-13 10:22:15 +0000
518@@ -0,0 +1,67 @@
519+# Introduction {#mainpage}
520+
521+Ubuntu's location service is a central hub for multiplexing access to
522+positioning subsystems available via hard- and software. It provides a
523+client API offering positioning capabilities to applications and other
524+system components, abstracting away the details of individual
525+positioning solutions.
526+
527+## Vocabulary
528+
529+To make the remainder of this documentation as easily understandable
530+as possible, we start over with introducing some vocabulary:
531+
532+- Engine:
533+ Responsible for handling input from multiple positioning
534+ subsystems and maintaining the state of the overall system. Think
535+ about it like the heart of the system.
536+
537+- Provider:
538+ A positioning subsystem that feeds into the positioning
539+ engine. Common examples are a GPS provider or a network-based
540+ positioning provider.
541+
542+- Service:
543+ The point of entry for applications and services that would
544+ like to receive position data.
545+
546+- Session:
547+ In order to receive position information, every application
548+ or service has to create a session with the location Service.
549+
550+- Update: An update is a timestamped entity to a certain type of data.
551+
552+- [WGS84, http://en.wikipedia.org/wiki/World_Geodetic_System]: The coordinate system that is used throughout the entire location subsystem.
553+
554+## Architectural Overview
555+
556+The high-level architecture of the service is shown in the following diagram:
557+
558+![High-level architectural overview](images/LocationServiceHighLevel.png)
559+
560+In this diagram, the configuration of the engine refers to:
561+
562+ * The current state of any satellite-based positioning subsystems. Can either be off or on.
563+ * 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.
564+ * The overall state of the engine. Can either be off, on or active.
565+
566+The Service takes this configuration and exposes it to client
567+applications. In addition, mainly for debugging purposes, the set of
568+currently visible satellites (if any) is maintained and exposed to
569+privileged client applications.
570+
571+## Privacy & Access Control
572+
573+Location information is highly privacy relevant. For this reason, the
574+location service is deeply integrated with AppArmor and Ubuntu's
575+overall trust infrastructure. Every incoming session request is
576+validated and if in doubt, the user is asked to explicitly grant trust
577+to the application requesting access to positioning
578+information. Please see [@ref com::ubuntu::location::service::PermissionManager]
579+for further details.
580+
581+In addition, the location service allows for selectively adjusting the
582+accuracy and reporting setup of the location Engine to provide further
583+fine-grained control over the exposed data to user. Within this setup,
584+a user is able to entirely disable all positioning.
585+
586
587=== added file 'doc/manual_testing.md'
588--- doc/manual_testing.md 1970-01-01 00:00:00 +0000
589+++ doc/manual_testing.md 2015-11-13 10:22:15 +0000
590@@ -0,0 +1,174 @@
591+# Manual Testplan
592+
593+[TOC]
594+
595+While the automatic test suite of the location service is
596+comprehensive and covers large parts of the functionality of the
597+service itself, we still provide an additional level of acceptance
598+testing covering the entire location stack/experience as a part of
599+this document.
600+
601+## Dependents/Clients
602+
603+ - qtubuntu-sensors
604+ - Qt/QML applications:
605+ - Browser
606+ - osmTouch
607+
608+## Test Plan
609+
610+This test plan is not supposed to be complete; use it to guide your
611+manual testing so you don't miss big functional areas that are part of
612+the component; also this should be used as guideline to inspire the
613+exploratory testing which should be adapted smartly based on the real
614+content of a MP.
615+
616+Please note that if you're testing the GPS provider, the location
617+service relies on GPS hardware to obtain a location fix. For that, it
618+might be required that you execute the manual steps listed before
619+close to a window or ideally outside, with good satellite visibility
620+conditions.
621+
622+__Note: It can take up to 15 minutes for the GPS device to get a lock, due to lack of assisted GPS__
623+
624+ - Install latest image on phone
625+ - Install freshly built MPs that are needed for landing
626+
627+Depending on the default configuration of location-service on the
628+image, you may skip parts of this test plan. E.g. if GPS hardware is
629+disabled, skip this part. You can see which providers are enabled by
630+looking at the list of providers on the location-serviced command-line
631+(`ps fauxw | grep location-service`, then look at the `--provider`
632+flags).
633+
634+### Dummy provider
635+
636+This tests forces location-service to use only the dummy provider;
637+this providers a baseline test for the app to trust-store to
638+location-service path.
639+
640+ - phablet-shell into the phone:
641+ - `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`
642+ - As phablet, start the trust store again (it stops when location-service is stopped) with: `start ubuntu-location-service-trust-stored`
643+ - Ensure that all AP tests for the webbrowser pass as expected
644+ - Point the browser to maps.google.com (alternatively: here.com, maps.bing.fr).
645+ - Request centering the map on current position and observe if it works correctly (should show the Eiffel tower)
646+ - Install osmTouch from the app store
647+ - Launch osmTouch and check if it centers on the Eiffel tower.
648+ - Install a maps webapp such as HERE or Google Maps webapp from the app store
649+ - Launch maps webapp and check if it centers on the Eiffel tower.
650+
651+### GPS Test Plan
652+
653+This applies only if GPS provider is enabled.
654+
655+ - (If applicable: Remember to add the silo you are testing)
656+ - `sudo apt-get install ubuntu-location-service-tests`
657+ - 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:
658+ - `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`
659+ - If you '''don't''' want to send off crowdsourced information:
660+ - `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`
661+
662+ - The test will output a lot of diagnostic information to the
663+ terminal and will take ~30 minutes. If satellite visibility is
664+ limited, it can take even longer. The test will automatically
665+ report success or failure.
666+
667+### Preliminary AGPS Test Plan
668+
669+**Does not apply to Krillin**
670+
671+Please note that the Krillin GPS chipset driver and its integration
672+within Ubuntu does not support vanilla AGPS (i.e., SUPL) right
673+now. For that, this test case is irrelevant for Krillin and is likely
674+to fail.
675+
676+This applied only if GPS provider and some other provider (giving
677+_A_ssistance) are enabled.
678+
679+ - Add the silo.
680+ - `sudo apt-get install ubuntu-location-service-tests`
681+ - Obtain a (rough) location estimate for your current location on Google maps.
682+ - Make sure to replace INSERT_ESTIMATE_HERE with the respective
683+ values obtained from Google maps.
684+ - If you want to send off crowdsourced information, i.e., information
685+ about visible wifis and visible radio cells for the obtained
686+ location fixes to Mozilla's location service and our own instance:
687+ - `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`
688+ - If you '''don't''' want to send off crowdsourced information:
689+ - `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`
690+
691+ - The test will output a lot of diagnostic information to the
692+ terminal and will take ~10 minutes or less. The test will
693+ automatically report success or failure.
694+
695+### Espoo / HERE provider
696+
697+This applies only if the Espoo / HERE remote provider is enabled. This
698+provider should be enabled by default and may either work standalone
699+as the only provider or as an assistance for the GPS hardware to lock.
700+
701+ - Add the silo; special exception for lxc-android-config: see https://wiki.ubuntu.com/Touch/Testing/lxc-android-config
702+ - If noted, deploy an updated custom tarball:
703+ - Download the tarball under /tmp ('''NOT''' under /)
704+ - Unpack there: `cd /tmp; sudo tar xvf custom-vendor-here-*.tar.xz`
705+ - Remove older bits: `sudo rm -rf /custom/vendor/here/`
706+ - Update custom bits: `sudo mv /tmp/system/custom/vendor/here /custom/vendor`
707+ - Reboot
708+ - After boot, check you have these three processes running on top of location-service:
709+ - slpgwd
710+ - posclientd
711+ - ubuntu-espoo-service
712+ - Make sure SIM is unlocked and attached to the network (has some reliable signal) and that WiFi is turned on.
713+ - Install OSMTouch app
714+ - Run OSMTouch app, hit the position button every other second until you get a blue circle showing your current location;
715+
716+# Connectivity API
717+
718+For integration of network-based positioning providers, the location
719+service offers a connectivity API that provides access to wifi and
720+cell measurements as well as information on the current overall
721+connectivity status of the device. Please execute the following
722+commands on a newly flashed device with a writable image:
723+
724+ - `sudo apt-get update && sudo apt-get build-dep location-service && sudo apt-get install libubuntu-location-service-dev ubuntu-location-service-examples`
725+ - `mkdir /tmp/build && cd /tmp/build && cmake /usr/share/ubuntu-location-service/examples/standalone/connectivity/ && make`
726+ - `GLOG_logtostderr=1 ./connectivity`
727+
728+Verify that the output looks similar to:
729+
730+ phablet@ubuntu-phablet:/tmp/build$ ./connectivity
731+ Is wifi enabled: true
732+ Is wifi hw enabled: true
733+ Is wwan enabled: false
734+ Is wwan hw enabled: true
735+ umts(mcc: 262, mnc: 2, lac: 5313, id: 131948771, asu: 7)
736+ (bssid: BC:F2:AF:AF:19:A2, ssid: devolo-bcf2afaf19a2, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2462, strength: 72)
737+ (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 24)
738+ (bssid: 82:C7:A6:40:8C:4E, ssid: EasyBox-44D054, last seen: 1408955206, mode: Mode::infrastructure, frequency: 2417, strength: 17)
739+ (bssid: 00:24:01:B8:32:8D, ssid: gra, last seen: 1408955086, mode: Mode::infrastructure, frequency: 2412, strength: 12)
740+ (bssid: C0:25:06:3C:28:22, ssid: FRITZ!Box 6360 Cable, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2412, strength: 17)
741+ (bssid: 00:1C:4A:A5:B7:59, ssid: FRITZ!Box Fon WLAN 7170, last seen: 1408954966, mode: Mode::infrastructure, frequency: 2437, strength: 10)
742+ 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)
743+ Last seen changed for wifi (bssid: 00:22:3F:35:43:58, ssid: JustAnotherWLAN, last seen: 1408955257, mode: Mode::infrastructure, frequency: 2412, strength: 24)
744+ 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)
745+
746+# Trust Store Integration
747+
748+Please note that we are assuming a freshly wiped system for testing
749+here. If you cannot fulfill that pre-condition, please run `rm -rf
750+/home/phablet/.local/share/UbuntuLocationService && sudo shutdown -r` prior to running the
751+tests:
752+
753+## Unconfined
754+
755+ - Open the browser, go to maps.google.com
756+ - Observe the in-browser dialog asking for granting access to location.
757+
758+## Confined Web-App
759+
760+ - Open the Nokia Here web app, observe the trust dialog appearing.
761+
762+## Confined Application
763+
764+ - Open osmtouch and observe the osmtouch surface sliding up, presenting you with a trust dialog.
765
766=== added file 'doc/tips_n_tricks.md'
767--- doc/tips_n_tricks.md 1970-01-01 00:00:00 +0000
768+++ doc/tips_n_tricks.md 2015-11-13 10:22:15 +0000
769@@ -0,0 +1,21 @@
770+# Tips'n'Tricks
771+
772+## Mark HERE license as accepted from cmdline
773+
774+ 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>'
775+
776+## Force startup after ofono and NM are started
777+
778+This is a *workaround* to get connectivity API to collect; mount your
779+system read-write and edit
780+/etc/init/ubuntu-location-provider-here-slpgwd.conf:
781+
782+ sudo mount -o remount,rw /
783+ sudo vi /etc/init/ubuntu-location-provider-here-slpgwd.conf
784+
785+change: `start on started dbus and (started ofono or started network-manager)`
786+to: `start on started dbus and started ofono and started network-manager`
787+
788+ sudo mount -o remount,ro /
789+ sync
790+ sudo reboot
791
792=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp'
793--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2014-10-27 21:58:16 +0000
794+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2015-11-13 10:22:15 +0000
795@@ -66,8 +66,6 @@
796 if (config.count("XTRA_SERVER_3") > 0)
797 result.xtra_hosts.push_back(config.get<std::string>("XTRA_SERVER_3"));
798
799- result.timeout = std::chrono::milliseconds{1500};
800-
801 return result;
802 }
803
804@@ -333,14 +331,14 @@
805 } else
806 {
807 auto now = location::Clock::now().time_since_epoch();
808- auto thiz = static_cast<android::HardwareAbstractionLayer*>(context);
809+ auto ms_since_epoch = std::chrono::duration_cast<std::chrono::milliseconds>(now);
810
811 static const int zero_uncertainty = 0;
812
813 u_hardware_gps_inject_time(
814 thiz->impl.gps_handle,
815- now.count(),
816- now.count(),
817+ ms_since_epoch.count(),
818+ ms_since_epoch.count(),
819 zero_uncertainty);
820 }
821 }
822
823=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h'
824--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2015-04-22 13:30:04 +0000
825+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h 2015-11-13 10:22:15 +0000
826@@ -49,7 +49,7 @@
827 /** @brief Timeout on gps xtra download operations. */
828 std::chrono::milliseconds timeout
829 {
830- 5000
831+ 30000
832 };
833
834 /** Set of hosts serving GPS xtra data. */
835
836=== modified file 'src/location_service/com/ubuntu/location/service/daemon.cpp'
837--- src/location_service/com/ubuntu/location/service/daemon.cpp 2015-04-16 10:03:29 +0000
838+++ src/location_service/com/ubuntu/location/service/daemon.cpp 2015-11-13 10:22:15 +0000
839@@ -20,6 +20,8 @@
840 #include <com/ubuntu/location/boost_ptree_settings.h>
841 #include <com/ubuntu/location/provider_factory.h>
842
843+#include <com/ubuntu/location/connectivity/dummy_connectivity_manager.h>
844+
845 #include <com/ubuntu/location/service/default_configuration.h>
846 #include <com/ubuntu/location/service/demultiplexing_reporter.h>
847 #include <com/ubuntu/location/service/ichnaea_reporter.h>
848@@ -214,29 +216,8 @@
849 dc.the_permission_manager(config.outgoing),
850 location::service::Harvester::Configuration
851 {
852- location::connectivity::platform_default_manager(),
853- // We submit location/wifi/cell measurements to both
854- // Mozilla's location service and to Ubuntu's own instance.
855- std::make_shared<service::DemultiplexingReporter>(
856- std::initializer_list<service::Harvester::Reporter::Ptr>
857- {
858- std::make_shared<service::ichnaea::Reporter>(
859- service::ichnaea::Reporter::Configuration
860- {
861- "https://location.services.mozilla.com",
862- "UbuntuLocationService",
863- "UbuntuLocationService"
864- }
865- ),
866- std::make_shared<service::ichnaea::Reporter>(
867- service::ichnaea::Reporter::Configuration
868- {
869- "https://162.213.35.107",
870- "UbuntuLocationService",
871- "UbuntuLocationService"
872- }
873- )
874- })
875+ std::make_shared<dummy::ConnectivityManager>(),
876+ std::make_shared<NullReporter>()
877 }
878 };
879
880
881=== modified file 'src/location_service/com/ubuntu/location/service/session/skeleton.cpp'
882--- src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2014-08-14 20:31:09 +0000
883+++ src/location_service/com/ubuntu/location/service/session/skeleton.cpp 2015-11-13 10:22:15 +0000
884@@ -283,7 +283,13 @@
885 VLOG(10) << __PRETTY_FUNCTION__;
886 try
887 {
888- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdatePosition, void>(position);
889+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdatePosition, void>([](const core::dbus::Result<void>& result)
890+ {
891+ if (result.is_error())
892+ {
893+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
894+ }
895+ }, position);
896 } catch(const std::exception&)
897 {
898 // We consider the session to be dead once we hit an exception here.
899@@ -300,7 +306,13 @@
900 VLOG(10) << __PRETTY_FUNCTION__;
901 try
902 {
903- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateHeading, void>(heading);
904+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateHeading, void>([](const core::dbus::Result<void>& result)
905+ {
906+ if (result.is_error())
907+ {
908+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
909+ }
910+ }, heading);
911 } catch(const std::exception&)
912 {
913 // We consider the session to be dead once we hit an exception here.
914@@ -317,7 +329,13 @@
915 VLOG(10) << __PRETTY_FUNCTION__;
916 try
917 {
918- configuration.remote.object->invoke_method_asynchronously<culs::session::Interface::UpdateVelocity, void>(velocity);
919+ configuration.remote.object->invoke_method_asynchronously_with_callback<culs::session::Interface::UpdateVelocity, void>([](const core::dbus::Result<void>& result)
920+ {
921+ if (result.is_error())
922+ {
923+ LOG(INFO) << "Failed to communicate position update to client: " << result.error().print();
924+ }
925+ }, velocity);
926 } catch(const std::exception&)
927 {
928 // We consider the session to be dead once we hit an exception here.
929
930=== modified file 'tests/gps_provider_test.cpp'
931--- tests/gps_provider_test.cpp 2015-01-12 08:41:14 +0000
932+++ tests/gps_provider_test.cpp 2015-11-13 10:22:15 +0000
933@@ -48,6 +48,31 @@
934
935 namespace
936 {
937+
938+struct MockHardwareGps
939+{
940+ MockHardwareGps()
941+ {
942+ instance_ = this;
943+ }
944+ ~MockHardwareGps()
945+ {
946+ instance_ = nullptr;
947+ }
948+
949+ MOCK_METHOD5(set_position_mode, bool(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t));
950+ MOCK_METHOD3(inject_time, void(int64_t, int64_t, int));
951+
952+ static MockHardwareGps *mocked(UHardwareGps self) {
953+ return reinterpret_cast<MockHardwareGps*>(self);
954+ }
955+ static MockHardwareGps *instance() { return instance_; }
956+
957+ static MockHardwareGps *instance_;
958+};
959+
960+MockHardwareGps *MockHardwareGps::instance_ = nullptr;
961+
962 struct UpdateTrap
963 {
964 MOCK_METHOD1(on_position_updated, void(const location::Position&));
965@@ -211,6 +236,42 @@
966
967 }
968
969+/* Mock the hardware GPS platform API: the methods defined here will be invoked
970+ * instead of those exported by the system library.
971+ * We redefine these methods using the MockHardwareGps class above, which is
972+ * implemented using google-mock. This effectively allows us to test that the
973+ * right calls to the platform API are made.
974+ */
975+UHardwareGps
976+u_hardware_gps_new(UHardwareGpsParams *)
977+{
978+ using namespace ::testing;
979+
980+ return reinterpret_cast<UHardwareGps>(MockHardwareGps::instance());
981+}
982+
983+void
984+u_hardware_gps_delete(UHardwareGps)
985+{
986+}
987+
988+bool
989+u_hardware_gps_set_position_mode(UHardwareGps self, uint32_t mode, uint32_t recurrence,
990+ uint32_t min_interval, uint32_t preferred_accuracy,
991+ uint32_t preferred_time)
992+{
993+ MockHardwareGps *thiz = MockHardwareGps::mocked(self);
994+ return thiz->set_position_mode(mode, recurrence, min_interval,
995+ preferred_accuracy, preferred_time);
996+}
997+
998+void
999+u_hardware_gps_inject_time(UHardwareGps self, int64_t time, int64_t time_reference, int uncertainty)
1000+{
1001+ MockHardwareGps* thiz = MockHardwareGps::mocked(self);
1002+ return thiz->inject_time(time, time_reference, uncertainty);
1003+}
1004+
1005 TEST(AndroidGpsXtraDownloader, reading_configuration_from_valid_conf_file_works)
1006 {
1007 std::stringstream ss{gps_conf};
1008@@ -261,6 +322,28 @@
1009 provider.on_reference_location_updated(pos);
1010 }
1011
1012+TEST(GpsProvider, time_requests_inject_current_time_into_the_hal)
1013+{
1014+ using namespace ::testing;
1015+
1016+ NiceMock<MockHardwareGps> hardwareGps;
1017+
1018+ gps::android::HardwareAbstractionLayer::Configuration configuration;
1019+ gps::android::HardwareAbstractionLayer hal(configuration);
1020+ std::shared_ptr<gps::HardwareAbstractionLayer> hal_ptr(&hal, [](gps::HardwareAbstractionLayer*){});
1021+
1022+ gps::Provider provider(hal_ptr);
1023+ int64_t time = 0;
1024+ EXPECT_CALL(hardwareGps, inject_time(_, _, 0)).Times(1).WillOnce(SaveArg<0>(&time));
1025+
1026+ auto t0 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
1027+
1028+ gps::android::HardwareAbstractionLayer::on_request_utc_time(&hal);
1029+
1030+ auto t1 = std::chrono::duration_cast<std::chrono::milliseconds>(location::Clock::now().time_since_epoch());
1031+ EXPECT_THAT(time, AllOf(Ge(t0.count()), Le(t1.count())));
1032+}
1033+
1034 TEST(GpsProvider, updates_from_hal_are_passed_on_by_the_provider)
1035 {
1036 using namespace ::testing;
1037
1038=== added directory 'tools'
1039=== added file 'tools/CMakeLists.txt'
1040--- tools/CMakeLists.txt 1970-01-01 00:00:00 +0000
1041+++ tools/CMakeLists.txt 2015-11-13 10:22:15 +0000
1042@@ -0,0 +1,1 @@
1043+configure_file(symbol_diff.in symbol_diff)
1044
1045=== added file 'tools/symbol_diff.in'
1046--- tools/symbol_diff.in 1970-01-01 00:00:00 +0000
1047+++ tools/symbol_diff.in 2015-11-13 10:22:15 +0000
1048@@ -0,0 +1,70 @@
1049+#! /usr/bin/env python3
1050+
1051+#
1052+# Copyright (C) 2014 Canonical Ltd
1053+#
1054+# This program is free software: you can redistribute it and/or modify
1055+# it under the terms of the GNU Lesser General Public License version 3 as
1056+# published by the Free Software Foundation.
1057+#
1058+# This program is distributed in the hope that it will be useful,
1059+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1060+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1061+# GNU Lesser General Public License for more details.
1062+#
1063+# You should have received a copy of the GNU Lesser General Public License
1064+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1065+#
1066+# Authored by: Michi Henning <michi.henning@canonical.com>
1067+#
1068+
1069+import re
1070+import subprocess
1071+
1072+OLD_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.symbols'
1073+NEW_FILE = './debian/libubuntu-location-service@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@/DEBIAN/symbols'
1074+
1075+def run():
1076+ old_regex = re.compile(r'^ (\(.*\))"(.*)" (.*)$')
1077+
1078+ old_syms = {} # Dictionary containing symbol -> ( tag, version )
1079+ with open(OLD_FILE, encoding='utf=8') as file:
1080+ file.readline() # Skip first line, which is the library name and version
1081+ for line in file:
1082+ mo = old_regex.match(line)
1083+ if mo:
1084+ old_syms[mo.group(2)] = ( mo.group(1), mo.group(3) )
1085+ else:
1086+ raise Exception('Invalid input line in ' + OLD_FILE + ': ' + line)
1087+
1088+ new_regex = re.compile(r'^ (.*) .+$')
1089+
1090+ # Run the new symbols file through "c++filt | sort | uniq". We need
1091+ # the sort | uniq because, otherwise, we end up with duplicate demangled symbols.
1092+ with open(NEW_FILE) as infile, open('new_symbols', 'w') as outfile:
1093+ p = subprocess.Popen(['c++filt | sort | uniq'], shell=True, stdin=infile, stdout=subprocess.PIPE)
1094+
1095+ # For each symbol, if it is in the old dictionary, output the tags from the original
1096+ # symbol file, followed by the symbol and version. Otherwise, use "(c++)" as the tag
1097+ # and add " 0replaceme", so the new symbol will be accepted.
1098+ line = p.stdout.readline().decode('utf-8')
1099+ outfile.write(line) # Write library name and version
1100+ for line in p.stdout:
1101+ mo = new_regex.match(line.decode('utf-8'))
1102+ if (mo):
1103+ sym = mo.group(1)
1104+ try:
1105+ tag, version = old_syms[sym]
1106+ except KeyError:
1107+ tag = '(c++)'
1108+ version = '0replaceme'
1109+ outfile.write(' {}"{}" {}\n'.format(tag, sym, version))
1110+ else:
1111+ raise Exception('Cannot parse demangled line: ' + line)
1112+
1113+ # Write the diff into /tmp/symbols.diff
1114+ with open('/tmp/symbols.diff', 'w') as outfile:
1115+ subprocess.call(['diff', '-u', OLD_FILE, 'new_symbols'], stdout=outfile)
1116+
1117+if __name__ == '__main__':
1118+ run()

Subscribers

People subscribed via source and target branches