~thomas-voss/location-service/fix-1347887

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/service/session/interface.h

This MP consolidates multiple related changes together, with the goal of:

(1.) Make the service instance accessible via a cli. Useful for testing scenarios.
(2.) To cut down time-to-first-fix (ttff) by:
  (2.1) Leveraging SUPL and other supplementary data downloaded over ordinary data connections.
  (2.2) Enabling network-based positioning providers to acquire fast position estimates.

In more detail:

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio. Fixes: 1226204, 1248973, 1281817

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
19
19
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
20
20
 
21
 
#include "com/ubuntu/location/channel.h"
22
 
#include "com/ubuntu/location/heading.h"
23
 
#include "com/ubuntu/location/position.h"
24
 
#include "com/ubuntu/location/provider.h"
25
 
#include "com/ubuntu/location/update.h"
26
 
#include "com/ubuntu/location/velocity.h"
 
21
#include <com/ubuntu/location/heading.h>
 
22
#include <com/ubuntu/location/position.h>
 
23
#include <com/ubuntu/location/provider.h>
 
24
#include <com/ubuntu/location/update.h>
 
25
#include <com/ubuntu/location/velocity.h>
27
26
 
28
 
#include <core/dbus/codec.h>
29
 
#include <core/dbus/traits/service.h>
30
 
#include <core/dbus/types/object_path.h>
 
27
#include <core/property.h>
31
28
 
32
29
namespace com
33
30
{
39
36
{
40
37
namespace session
41
38
{
 
39
/**
 
40
 * @brief Models a session with the location service.
 
41
 */
42
42
class Interface
43
43
{
44
44
public:
45
 
    struct UpdatePosition
46
 
    {
47
 
        typedef com::ubuntu::location::service::session::Interface Interface;
48
 
 
49
 
        inline static const std::string& name()
50
 
        {
51
 
            static const std::string s
52
 
            {
53
 
                "UpdatePosition"
54
 
            };
55
 
            return s;
56
 
        }
57
 
 
58
 
        typedef void ResultType;
59
 
 
60
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::milliseconds{250}; }
61
 
    };
62
 
 
63
 
    struct UpdateVelocity
64
 
    {
65
 
        typedef com::ubuntu::location::service::session::Interface Interface;
66
 
 
67
 
        inline static const std::string& name()
68
 
        {
69
 
            static const std::string s
70
 
            {
71
 
                "UpdateVelocity"
72
 
            };
73
 
            return s;
74
 
        }
75
 
 
76
 
        typedef void ResultType;
77
 
 
78
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::milliseconds{250}; }
79
 
    };
80
 
 
81
 
    struct UpdateHeading
82
 
    {
83
 
        typedef com::ubuntu::location::service::session::Interface Interface;
84
 
 
85
 
        inline static const std::string& name()
86
 
        {
87
 
            static const std::string s
88
 
            {
89
 
                "UpdateHeading"
90
 
            };
91
 
            return s;
92
 
        }
93
 
 
94
 
        typedef void ResultType;
95
 
 
96
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::milliseconds{250}; }
97
 
    };
98
 
 
99
 
    struct StartPositionUpdates
100
 
    {
101
 
        typedef com::ubuntu::location::service::session::Interface Interface;
102
 
 
103
 
        inline static const std::string& name()
104
 
        {
105
 
            static const std::string s
106
 
            {
107
 
                "StartPositionUpdates"
108
 
            };
109
 
            return s;
110
 
        }
111
 
 
112
 
        typedef void ResultType;
113
 
 
114
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
115
 
    };
116
 
 
117
 
    struct StopPositionUpdates
118
 
    {
119
 
        typedef com::ubuntu::location::service::session::Interface Interface;
120
 
 
121
 
        inline static const std::string& name()
122
 
        {
123
 
            static const std::string s
124
 
            {
125
 
                "StopPositionUpdates"
126
 
            };
127
 
            return s;
128
 
        }
129
 
 
130
 
        typedef void ResultType;
131
 
 
132
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
133
 
    };
134
 
 
135
 
    struct StartVelocityUpdates
136
 
    {
137
 
        typedef com::ubuntu::location::service::session::Interface Interface;
138
 
 
139
 
        inline static const std::string& name()
140
 
        {
141
 
            static const std::string s
142
 
            {
143
 
                "StartVelocityUpdates"
144
 
            };
145
 
            return s;
146
 
        }
147
 
 
148
 
        typedef void ResultType;
149
 
 
150
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
151
 
    };
152
 
 
153
 
    struct StopVelocityUpdates
154
 
    {
155
 
        typedef com::ubuntu::location::service::session::Interface Interface;
156
 
 
157
 
        inline static const std::string& name()
158
 
        {
159
 
            static const std::string s
160
 
            {
161
 
                "StopVelocityUpdates"
162
 
            };
163
 
            return s;
164
 
        }
165
 
 
166
 
        typedef void ResultType;
167
 
 
168
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
169
 
    };
170
 
 
171
 
    struct StartHeadingUpdates
172
 
    {
173
 
        typedef com::ubuntu::location::service::session::Interface Interface;
174
 
 
175
 
        inline static const std::string& name()
176
 
        {
177
 
            static const std::string s
178
 
            {
179
 
                "StartHeadingUpdates"
180
 
            };
181
 
            return s;
182
 
        }
183
 
 
184
 
        typedef void ResultType;
185
 
 
186
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
187
 
    };
188
 
 
189
 
    struct StopHeadingUpdates
190
 
    {
191
 
        typedef com::ubuntu::location::service::session::Interface Interface;
192
 
 
193
 
        inline static const std::string& name()
194
 
        {
195
 
            static const std::string s
196
 
            {
197
 
                "StopHeadingUpdates"
198
 
            };
199
 
            return s;
200
 
        }
201
 
 
202
 
        typedef void ResultType;
203
 
 
204
 
        inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
205
 
    };
 
45
    struct UpdatePosition;
 
46
    struct UpdateVelocity;
 
47
    struct UpdateHeading;
 
48
 
 
49
    struct StartPositionUpdates;
 
50
    struct StopPositionUpdates;
 
51
 
 
52
    struct StartVelocityUpdates;
 
53
    struct StopVelocityUpdates;
 
54
 
 
55
    struct StartHeadingUpdates;
 
56
    struct StopHeadingUpdates;
206
57
 
207
58
    struct Errors
208
59
    {
209
 
        struct ErrorParsingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorParsingUpdate"; } };
210
 
        struct ErrorStartingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorStartingUpdate"; } };
211
 
        struct ErrorStoppingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorStoppingUpdate"; } };
 
60
        struct ErrorParsingUpdate;
 
61
        struct ErrorStartingUpdate;
 
62
    };
 
63
    /**
 
64
     * @brief Encapsulates updates provided for this session, and the ability to enable/disable updates.
 
65
     */
 
66
    struct Updates
 
67
    {
 
68
        /**
 
69
         * @brief The Status enum models the possible states of updates.
 
70
         */
 
71
        enum class Status
 
72
        {
 
73
            enabled, ///< Updates are enabled and delivered to this session.
 
74
            disabled ///< Updates are disabled and not delivered to this session.
 
75
        };
 
76
 
 
77
        /**
 
78
         * @brief Updates for position measurements.
 
79
         */
 
80
        core::Property<Update<Position>> position{};
 
81
        /**
 
82
         * @brief Status of position updates, mutable.
 
83
         */
 
84
        core::Property<Status> position_status{Status::disabled};
 
85
 
 
86
        /**
 
87
         * @brief Updates for the heading measurements.
 
88
         */
 
89
        core::Property<Update<Heading>> heading{};
 
90
        /**
 
91
         * @brief Status of position updates, mutable.
 
92
         */
 
93
        core::Property<Status> heading_status{Status::disabled};
 
94
 
 
95
        /**
 
96
         * @brief Updates for velocity measurements.
 
97
         */
 
98
        core::Property<Update<Velocity>> velocity{};
 
99
        /**
 
100
         * @brief Status of velocity updates, mutable.
 
101
         */
 
102
        core::Property<Status> velocity_status{Status::disabled};
212
103
    };
213
104
 
214
105
    typedef std::shared_ptr<Interface> Ptr;
217
108
    virtual ~Interface() noexcept;
218
109
    Interface& operator=(const Interface&) = delete;
219
110
 
220
 
    virtual const core::dbus::types::ObjectPath& path() const = 0;
221
 
 
222
 
    ChannelConnection install_position_updates_handler(std::function<void(const Update<Position>&)> handler);
223
 
    ChannelConnection install_velocity_updates_handler(std::function<void(const Update<Velocity>&)> handler);
224
 
    ChannelConnection install_heading_updates_handler(std::function<void(const Update<Heading>&)> handler);
225
 
 
226
 
    virtual void start_position_updates() = 0;
227
 
    virtual void stop_position_updates() noexcept = 0;
228
 
    virtual void start_velocity_updates() = 0;
229
 
    virtual void stop_velocity_updates() noexcept = 0;
230
 
    virtual void start_heading_updates() = 0;
231
 
    virtual void stop_heading_updates() noexcept = 0;
232
 
 
233
 
protected:
 
111
    /**
 
112
     * @brief Provides access to the updates delivered for this session.
 
113
     * @return A mutable reference to updates.
 
114
     */
 
115
    virtual Updates& updates();
 
116
 
 
117
protected:    
234
118
    Interface();
235
119
 
236
 
    Channel<Update<Position>>& access_position_updates_channel();
237
 
    Channel<Update<Heading>>& access_heading_updates_channel();
238
 
    Channel<Update<Velocity>>& access_velocity_updates_channel();
239
 
 
240
120
private:
241
121
    struct Private;
242
 
    std::unique_ptr<Private> d;
243
 
};
244
 
}
245
 
}
246
 
}
247
 
}
248
 
}
249
 
namespace core
250
 
{
251
 
namespace dbus
252
 
{
253
 
namespace traits
254
 
{
255
 
template<>
256
 
struct Service<com::ubuntu::location::service::session::Interface>
257
 
{
258
 
    static const std::string& interface_name()
259
 
    {
260
 
        static const std::string s
261
 
        {
262
 
            "com.ubuntu.location.Service.Session"
263
 
        };
264
 
        return s;
265
 
    }
266
 
};
267
 
}
268
 
}
269
 
}
270
 
 
271
 
 
272
 
#include "com/ubuntu/location/codec.h"
 
122
    std::shared_ptr<Private> d;
 
123
};
 
124
}
 
125
}
 
126
}
 
127
}
 
128
}
273
129
 
274
130
#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_