Merge lp:~thomas-voss/location-service/fix-prompt-string into lp:location-service/trunk

Proposed by Thomas Voß
Status: Superseded
Proposed branch: lp:~thomas-voss/location-service/fix-prompt-string
Merge into: lp:location-service/trunk
Diff against target: 1174 lines (+899/-46) (has conflicts)
20 files modified
CMakeLists.txt (+14/-0)
_clang-format (+56/-0)
astyle-config (+43/-0)
debian/changelog (+38/-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)
po/ubuntu-location-service.pot (+7/-11)
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)
src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp (+1/-1)
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/fix-prompt-string
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+278802@code.launchpad.net

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

Commit message

Account for changes in trust-store w.r.t. assembling the description of a trust prompt.

Description of the change

Account for changes in trust-store w.r.t. assembling the description of a trust prompt.

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

Subscribers

People subscribed via source and target branches