Merge lp:~mardy/location-service/last-known-position into lp:location-service/trunk

Proposed by Alberto Mardegan
Status: Work in progress
Proposed branch: lp:~mardy/location-service/last-known-position
Merge into: lp:location-service/trunk
Diff against target: 360 lines (+132/-58)
8 files modified
include/location_service/com/ubuntu/location/codec.h (+86/-8)
include/location_service/com/ubuntu/location/service/interface.h (+23/-0)
include/location_service/com/ubuntu/location/service/skeleton.h (+2/-0)
include/location_service/com/ubuntu/location/service/stub.h (+1/-0)
src/location_service/com/ubuntu/location/service/implementation.cpp (+1/-19)
src/location_service/com/ubuntu/location/service/skeleton.cpp (+7/-1)
src/location_service/com/ubuntu/location/service/stub.cpp (+8/-1)
tests/acceptance_tests.cpp (+4/-29)
To merge this branch: bzr merge lp:~mardy/location-service/last-known-position
Reviewer Review Type Date Requested Status
Thomas Voß (community) code Approve
Review via email: mp+277358@code.launchpad.net

Commit message

Send last known position to the client as soon as the session starts

Description of the change

Send last known position to the client as soon as the session starts

To post a comment you must log in.
Revision history for this message
Thomas Voß (thomas-voss) wrote :

LGTM.

review: Approve (code)
217. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

218. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

219. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

220. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

221. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

222. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

223. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

224. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

225. By Thomas Voß

[ Alberto Mardegan ]
* Make sure that injected time is given in milliseconds
[ Thomas Voß ]
* Cherry-pick rev. 196 and 199 from lp:location-service. The changes
  got accidentally removed by merging the outstanding documentation
  branch.
* Handle responses of clients to updates asynchronously. Rely on
  dummy::ConnectivityManager as harvesting is disabled anyway. (LP:
  #1462664, #1387643)
[ Thomas Voß ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.
[ thomas-voss ]
* Add documentation for debugging, hacking and debugging the location
  service. Pull manual testing instructions over from the wiki. Add
  tools for formatting the source.
Approved by: Alberto Mardegan

226. By Thomas Voß

* Enable dual landings according to https://wiki.ubuntu.com/citrain/LandingProcess#Dual-landing_for_stable_and_devel:
  * Both vivid+overlay and xenial packages are built from the same source.
  * To account for differences in major revisions (necessary to handle the g++ 5 ABI break),
    we generate install files on the fly.
Approved by: Łukasz Zemczak

227. By Thomas Voß

Lower number of concurrent clients to stabilize acceptance test on loaded builders.
Approved by: Scott Sweeny

228. By CI Train Bot Account

Releasing 3.0.0+16.04.20160404-0ubuntu1

229. By Scott Sweeny

Use a fusion engine provider to generate higher quality position updates

230. By Scott Sweeny

Small fixes around provider loading

231. By CI Train Bot Account

Releasing 3.0.0+16.04.20160405-0ubuntu1

232. By CI Train Bot Account

Resync trunk.

233. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

234. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

235. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

236. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

237. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

238. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

239. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

240. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

241. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

242. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

243. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

244. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

245. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

246. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

247. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

248. By Thomas Voß

Fix #1584860. The NM update altered the type of LastSeen to int32. Fixes: #1584860
Approved by: Scott Sweeny

249. By CI Train Bot Account

Releasing 3.0.0+16.10.20160524.3-0ubuntu1

250. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

251. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

252. By Thomas Voß

Expose service::State to the bus. (LP: #1536774)

253. By CI Train Bot Account

Releasing 3.0.0+16.10.20160613.1-0ubuntu1

254. By CI Train Bot Account

Resync trunk.

255. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

256. By Scott Sweeny

Fusion provider: Always use an update that came from the same source as the previous used update (fixes LP: #1570878) (LP: #1570878)

257. By CI Train Bot Account

Releasing 3.0.0+16.10.20160616-0ubuntu1

258. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

259. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

260. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

261. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

262. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

263. By Alberto Mardegan

Don't sent last known position to new sessions

264. By Alberto Mardegan

WIP

265. By Alberto Mardegan

codec fixes

266. By Alberto Mardegan

Wrap update into a struct

Unmerged revisions

266. By Alberto Mardegan

Wrap update into a struct

265. By Alberto Mardegan

codec fixes

264. By Alberto Mardegan

WIP

262. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

261. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/location_service/com/ubuntu/location/codec.h'
2--- include/location_service/com/ubuntu/location/codec.h 2016-05-20 15:24:39 +0000
3+++ include/location_service/com/ubuntu/location/codec.h 2016-07-27 06:58:25 +0000
4@@ -108,6 +108,35 @@
5 };
6 }
7
8+namespace helper
9+{
10+template<typename T>
11+struct TypeMapper<com::ubuntu::location::Optional<T>>
12+{
13+ constexpr static ArgumentType type_value()
14+ {
15+ return ArgumentType::structure;
16+ }
17+
18+ constexpr static bool is_basic_type()
19+ {
20+ return false;
21+ }
22+ constexpr static bool requires_signature()
23+ {
24+ return true;
25+ }
26+
27+ static std::string signature()
28+ {
29+ static const std::string s =
30+ helper::TypeMapper<bool>::signature() +
31+ helper::TypeMapper<T>::signature();
32+ return s;
33+ }
34+};
35+}
36+
37 template<typename T>
38 struct Codec<com::ubuntu::location::Optional<T>>
39 {
40@@ -115,18 +144,22 @@
41 {
42 bool has_value{in};
43 Codec<bool>::encode_argument(writer, has_value);
44+ typename com::ubuntu::location::Optional<T>::value_type value;
45 if (has_value)
46- Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, *in);
47+ {
48+ value = *in;
49+ }
50+ Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, value);
51 }
52
53 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Optional<T>& in)
54 {
55 bool has_value{false};
56 Codec<bool>::decode_argument(reader, has_value);
57+ typename com::ubuntu::location::Optional<T>::value_type value;
58+ Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);
59 if (has_value)
60 {
61- typename com::ubuntu::location::Optional<T>::value_type value;
62- Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);
63 in = value;
64 } else
65 {
66@@ -165,6 +198,43 @@
67 }
68 };
69
70+namespace helper
71+{
72+template<>
73+struct TypeMapper<com::ubuntu::location::Position>
74+{
75+ constexpr static ArgumentType type_value()
76+ {
77+ return ArgumentType::structure;
78+ }
79+ constexpr static bool is_basic_type()
80+ {
81+ return false;
82+ }
83+ constexpr static bool requires_signature()
84+ {
85+ return true;
86+ }
87+
88+ inline static std::string signature()
89+ {
90+ std::string s =
91+ //DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
92+ // latitude
93+ TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
94+ // longitude
95+ TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
96+ // optional altitude
97+ TypeMapper<com::ubuntu::location::Optional<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length>>>::signature() +
98+ // accuracy
99+ TypeMapper<com::ubuntu::location::Optional<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length>>>::signature() +
100+ TypeMapper<com::ubuntu::location::Optional<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length>>>::signature();// +
101+ //DBUS_STRUCT_END_CHAR_AS_STRING;
102+ return s;
103+ }
104+};
105+}
106+
107 template<>
108 struct Codec<com::ubuntu::location::Position>
109 {
110@@ -451,8 +521,10 @@
111 static std::string signature()
112 {
113 static const std::string s =
114+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
115 helper::TypeMapper<T>::signature() +
116- helper::TypeMapper<uint64_t>::signature();
117+ helper::TypeMapper<uint64_t>::signature() +
118+ DBUS_STRUCT_END_CHAR_AS_STRING;
119 return s;
120 }
121 };
122@@ -463,14 +535,20 @@
123 {
124 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Update<T>& in)
125 {
126- Codec<T>::encode_argument(writer, in.value);
127- Codec<int64_t>::encode_argument(writer, in.when.time_since_epoch().count());
128+ auto sub = writer.open_structure();
129+
130+ Codec<T>::encode_argument(sub, in.value);
131+ Codec<uint64_t>::encode_argument(sub, in.when.time_since_epoch().count());
132+
133+ writer.close_structure(std::move(sub));
134 }
135
136 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Update<T>& in)
137 {
138- Codec<T>::decode_argument(reader, in.value);
139- in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(reader.pop_int64()));
140+ auto sub = reader.pop_structure();
141+
142+ Codec<T>::decode_argument(sub, in.value);
143+ in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(sub.pop_uint64()));
144 }
145 };
146 }
147
148=== modified file 'include/location_service/com/ubuntu/location/service/interface.h'
149--- include/location_service/com/ubuntu/location/service/interface.h 2016-05-20 15:24:39 +0000
150+++ include/location_service/com/ubuntu/location/service/interface.h 2016-07-27 06:58:25 +0000
151@@ -173,6 +173,24 @@
152 static const bool readable = true;
153 static const bool writable = false;
154 };
155+
156+ struct LastKnownPosition
157+ {
158+ inline static const std::string& name()
159+ {
160+ static const std::string s
161+ {
162+ "LastKnownPosition"
163+ };
164+ return s;
165+ }
166+
167+ typedef com::ubuntu::location::service::Interface Interface;
168+ typedef com::ubuntu::location::Update<com::ubuntu::location::Position> ValueType;
169+
170+ static const bool readable = true;
171+ static const bool writable = false;
172+ };
173 };
174
175 Interface() = default;
176@@ -228,6 +246,11 @@
177 virtual core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles() = 0;
178
179 /**
180+ * @brief The last known position.
181+ */
182+ virtual core::Property<Update<Position>>& last_known_position() = 0;
183+
184+ /**
185 * @brief Starts a new session for the given criteria
186 * @throw std::runtime_error in case of errors.
187 * @param criteria The client's requirements in terms of accuraccy and functionality
188
189=== modified file 'include/location_service/com/ubuntu/location/service/skeleton.h'
190--- include/location_service/com/ubuntu/location/service/skeleton.h 2016-05-20 15:24:39 +0000
191+++ include/location_service/com/ubuntu/location/service/skeleton.h 2016-07-27 06:58:25 +0000
192@@ -116,6 +116,7 @@
193 core::Property<bool>& does_report_cell_and_wifi_ids();
194 core::Property<bool>& is_online();
195 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles();
196+ core::Property<Update<Position>>& last_known_position();
197
198 protected:
199 // Enable subclasses to alter the state.
200@@ -165,6 +166,7 @@
201 std::shared_ptr< core::dbus::Property<Interface::Properties::DoesReportCellAndWifiIds> > does_report_cell_and_wifi_ids;
202 std::shared_ptr< core::dbus::Property<Interface::Properties::IsOnline> > is_online;
203 std::shared_ptr< core::dbus::Property<Interface::Properties::VisibleSpaceVehicles> > visible_space_vehicles;
204+ std::shared_ptr< core::Property<Update<Position>> > last_known_position;
205 } properties;
206 // We sign up to property changes here, to be able to report them to the bus
207 struct
208
209=== modified file 'include/location_service/com/ubuntu/location/service/stub.h'
210--- include/location_service/com/ubuntu/location/service/stub.h 2016-05-20 15:24:39 +0000
211+++ include/location_service/com/ubuntu/location/service/stub.h 2016-07-27 06:58:25 +0000
212@@ -46,6 +46,7 @@
213 core::Property<bool>& does_report_cell_and_wifi_ids();
214 core::Property<bool>& is_online();
215 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles();
216+ core::Property<Update<Position>>& last_known_position();
217
218 private:
219 struct Private;
220
221=== modified file 'src/location_service/com/ubuntu/location/service/implementation.cpp'
222--- src/location_service/com/ubuntu/location/service/implementation.cpp 2016-05-20 15:24:39 +0000
223+++ src/location_service/com/ubuntu/location/service/implementation.cpp 2016-07-27 06:58:25 +0000
224@@ -177,23 +177,5 @@
225 new ProxyProvider{provider_selection}
226 };
227
228- session::Interface::Ptr session_iface{new session::Implementation(proxy_provider)};
229- std::weak_ptr<session::Interface> session_weak{session_iface};
230- session_iface->updates().position_status.changed().connect([this, session_weak](const session::Interface::Updates::Status& status)
231- {
232- cul::Optional<cul::Update<cul::Position>> last_known_position = configuration.engine->updates.last_known_location.get();
233- bool has_last_known_position = last_known_position ? true : false;
234- bool is_session_enabled = status == culs::session::Interface::Updates::Status::enabled;
235- bool is_session_on_or_active = configuration.engine->configuration.engine_state != Engine::Status::off;
236-
237- if (has_last_known_position && is_session_enabled && is_session_on_or_active)
238- {
239- // Immediately send the last known position to the client
240- if (auto session_iface = session_weak.lock())
241- {
242- session_iface->updates().position = last_known_position.get();
243- }
244- }
245- });
246- return session_iface;
247+ return session::Interface::Ptr{new culs::session::Implementation(proxy_provider)};
248 }
249
250=== modified file 'src/location_service/com/ubuntu/location/service/skeleton.cpp'
251--- src/location_service/com/ubuntu/location/service/skeleton.cpp 2016-05-20 15:24:39 +0000
252+++ src/location_service/com/ubuntu/location/service/skeleton.cpp 2016-07-27 06:58:25 +0000
253@@ -77,7 +77,8 @@
254 object->get_property<culs::Interface::Properties::DoesSatelliteBasedPositioning>(),
255 object->get_property<culs::Interface::Properties::DoesReportCellAndWifiIds>(),
256 object->get_property<culs::Interface::Properties::IsOnline>(),
257- object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>()
258+ object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>(),
259+ object->get_property<culs::Interface::Properties::LastKnownPosition>(),
260 },
261 connections
262 {
263@@ -291,6 +292,11 @@
264 return *properties.state;
265 }
266
267+core::Property<cul::Update<cul::Position>>& culs::Skeleton::last_known_position()
268+{
269+ return *properties.last_known_position;
270+}
271+
272 core::Property<bool>& culs::Skeleton::does_satellite_based_positioning()
273 {
274 return *properties.does_satellite_based_positioning;
275
276=== modified file 'src/location_service/com/ubuntu/location/service/stub.cpp'
277--- src/location_service/com/ubuntu/location/service/stub.cpp 2016-05-20 15:24:39 +0000
278+++ src/location_service/com/ubuntu/location/service/stub.cpp 2016-07-27 06:58:25 +0000
279@@ -38,7 +38,8 @@
280 does_satellite_based_positioning(object->get_property<culs::Interface::Properties::DoesSatelliteBasedPositioning>()),
281 does_report_cell_and_wifi_ids(object->get_property<culs::Interface::Properties::DoesReportCellAndWifiIds>()),
282 is_online(object->get_property<culs::Interface::Properties::IsOnline>()),
283- visible_space_vehicles(object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>())
284+ visible_space_vehicles(object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>()),
285+ last_known_position(object->get_property<culs::Interface::Properties::LastKnownPosition>())
286 {
287 }
288
289@@ -49,6 +50,7 @@
290 std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesReportCellAndWifiIds>> does_report_cell_and_wifi_ids;
291 std::shared_ptr<dbus::Property<culs::Interface::Properties::IsOnline>> is_online;
292 std::shared_ptr<dbus::Property<culs::Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
293+ std::shared_ptr<dbus::Property<culs::Interface::Properties::LastKnownPosition>> last_known_position;
294 };
295
296 culs::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub<culs::Interface>(connection),
297@@ -100,3 +102,8 @@
298 {
299 return *d->visible_space_vehicles;
300 }
301+
302+core::Property<cul::Update<cul::Position>>& culs::Stub::last_known_position()
303+{
304+ return *d->last_known_position;
305+}
306
307=== modified file 'tests/acceptance_tests.cpp'
308--- tests/acceptance_tests.cpp 2016-05-24 07:34:26 +0000
309+++ tests/acceptance_tests.cpp 2016-07-27 06:58:25 +0000
310@@ -666,7 +666,7 @@
311 EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(server, client));
312 }
313
314-TEST_F(LocationServiceStandalone, NewSessionsGetLastKnownPosition)
315+TEST_F(LocationServiceStandalone, LastKnownPositionCanBeQueried)
316 {
317 core::testing::CrossProcessSync sync_start;
318
319@@ -731,38 +731,13 @@
320 EXPECT_EQ(1, sync_start.wait_for_signal_ready_for(std::chrono::milliseconds{500}));
321
322 auto bus = session_bus();
323- bus->install_executor(dbus::asio::make_executor(bus));
324- std::thread t{[bus](){bus->run();}};
325-
326 auto location_service = dbus::resolve_service_on_bus<
327 cul::service::Interface,
328 cul::service::Stub>(bus);
329
330- auto s1 = location_service->create_session_for_criteria(cul::Criteria{});
331-
332- std::cout << "Successfully created session" << std::endl;
333-
334- cul::Update<cul::Position> position;
335- auto c1 = s1->updates().position.changed().connect(
336- [&](const cul::Update<cul::Position>& new_position) {
337- std::cout << "On position updated: " << new_position << std::endl;
338- position = new_position;
339- });
340-
341- std::cout << "Created event connections, starting updates..." << std::endl;
342-
343- s1->updates().position_status = culss::Interface::Updates::Status::enabled;
344-
345- std::cout << "done" << std::endl;
346-
347- std::this_thread::sleep_for(std::chrono::milliseconds{1000});
348-
349- bus->stop();
350-
351- if (t.joinable())
352- t.join();
353-
354- EXPECT_EQ(reference_position_update, position);
355+ auto lkp = location_service->last_known_position().get();
356+
357+ EXPECT_EQ(reference_position_update, lkp);
358
359 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
360 };

Subscribers

People subscribed via source and target branches