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

« back to all changes in this revision

Viewing changes to src/location_service/com/ubuntu/location/providers/dummy/provider.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:
31
31
{
32
32
namespace dummy
33
33
{
34
 
 
 
34
// Summarizes the configuration options known to the dummy provider.
35
35
struct Configuration
36
36
{
37
 
    inline static const char* key_update_period()
38
 
    {
39
 
        return "dummy::UpdatePeriodInMs";
40
 
    }
41
 
 
42
 
    inline static const char* key_reference_position_lat()
43
 
    {
44
 
        return "ReferenceLocationLat";
45
 
    }
46
 
 
47
 
    inline static const char* key_reference_position_lon()
48
 
    {
49
 
        return "ReferenceLocationLon";
50
 
    }
51
 
 
 
37
    // All configuration keys known to the dummy provider.
 
38
    struct Keys
 
39
    {
 
40
        static constexpr const char* update_period
 
41
        {
 
42
            "UpdatePeriodInMs"
 
43
        };
 
44
        static constexpr const char* reference_position_lat
 
45
        {
 
46
            "ReferenceLocationLat"
 
47
        };
 
48
        static constexpr const char* reference_position_lon
 
49
        {
 
50
            "ReferenceLocationLon"
 
51
        };
 
52
        static constexpr const char* reference_position_alt
 
53
        {
 
54
            "ReferenceLocationAlt"
 
55
        };
 
56
        static constexpr const char* reference_horizontal_accuracy
 
57
        {
 
58
            "ReferenceHorizontalAccuracy"
 
59
        };
 
60
        static constexpr const char* reference_vertical_accuracy
 
61
        {
 
62
            "ReferenceVerticalAccuracy"
 
63
        };
 
64
        static constexpr const char* reference_velocity
 
65
        {
 
66
            "ReferenceVelocity"
 
67
        };
 
68
        static constexpr const char* reference_heading
 
69
        {
 
70
            "ReferenceHeading"
 
71
        };
 
72
    };
 
73
 
 
74
    // Updates are delivered every update_period milliseconds.
52
75
    std::chrono::milliseconds update_period{500};
53
76
 
 
77
    // The reference position that is delivered in every upate cycle.
54
78
    Position reference_position
55
79
    {
56
 
        wgs84::Latitude{9. * units::Degrees},
57
 
        wgs84::Longitude{53. * units::Degrees},
58
 
        wgs84::Altitude{-2. * units::Meters}
 
80
        wgs84::Latitude
 
81
        {
 
82
            9. * units::Degrees
 
83
        },
 
84
        wgs84::Longitude
 
85
        {
 
86
            53. * units::Degrees
 
87
        },
 
88
        wgs84::Altitude
 
89
        {
 
90
            -2. * units::Meters
 
91
        }
 
92
    };
 
93
 
 
94
    // The reference velocity that is delivered in every update cycle.
 
95
    Velocity reference_velocity
 
96
    {
 
97
        9 * units::MetersPerSecond
 
98
    };
 
99
 
 
100
    // The reference heading that is delivered in every update cycle.
 
101
    Heading reference_heading
 
102
    {
 
103
        127 * units::Degrees
59
104
    };
60
105
};
61
106
 
64
109
  public:
65
110
    // For integration with the Provider factory.
66
111
    static std::string class_name();
 
112
    // Instantiates a new provider instance, populating the configuration object
 
113
    // from the provided property bundle. Please see dummy::Configuration::Keys
 
114
    // for the list of known options.
67
115
    static Provider::Ptr create_instance(const ProviderFactory::Configuration&);
68
116
 
 
117
    // Creates a new provider instance from the given configuration.
69
118
    Provider(const Configuration& config = Configuration{});
70
 
    Provider(const Provider&) = delete;
71
 
    Provider& operator=(const Provider&) = delete;
 
119
    // Cleans up all resources and stops the updates.
72
120
    ~Provider() noexcept;
73
121
 
74
 
    // From Provider
 
122
    // Always returns true.
75
123
    bool matches_criteria(const Criteria&);
76
124
 
 
125
    // Starts up the updater thread and delivers position updates
77
126
    void start_position_updates();
 
127
    // Stops the updater thread.
78
128
    void stop_position_updates();
79
129
 
80
130
  private: