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

« back to all changes in this revision

Viewing changes to src/location_service/com/ubuntu/location/service/stub.cpp

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:
15
15
 *
16
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17
17
 */
18
 
#include "com/ubuntu/location/service/stub.h"
19
 
#include "com/ubuntu/location/service/session/stub.h"
20
 
 
21
 
#include "com/ubuntu/location/logging.h"
 
18
#include <com/ubuntu/location/service/stub.h>
 
19
#include <com/ubuntu/location/service/session/stub.h>
 
20
 
 
21
#include <com/ubuntu/location/logging.h>
 
22
 
 
23
#include <core/dbus/property.h>
22
24
 
23
25
namespace cul = com::ubuntu::location;
24
26
namespace culs = com::ubuntu::location::service;
28
30
 
29
31
struct culs::Stub::Private
30
32
{
31
 
    core::dbus::Bus::Ptr bus;
32
 
    core::dbus::Object::Ptr object;
 
33
    Private(const dbus::Bus::Ptr& connection,
 
34
            const dbus::Object::Ptr& object)
 
35
        : bus(connection),
 
36
          object(object),
 
37
          does_satellite_based_positioning(object->get_property<culs::Interface::Properties::DoesSatelliteBasedPositioning>()),
 
38
          does_report_cell_and_wifi_ids(object->get_property<culs::Interface::Properties::DoesReportCellAndWifiIds>()),
 
39
          is_online(object->get_property<culs::Interface::Properties::IsOnline>()),
 
40
          visible_space_vehicles(object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>())
 
41
    {
 
42
        FLAGS_logtostderr = true;
 
43
        google::InitGoogleLogging("com.ubuntu.location");
 
44
    }
 
45
 
 
46
    dbus::Bus::Ptr bus;
 
47
    dbus::Object::Ptr object;
 
48
    std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesSatelliteBasedPositioning>> does_satellite_based_positioning;
 
49
    std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesReportCellAndWifiIds>> does_report_cell_and_wifi_ids;
 
50
    std::shared_ptr<dbus::Property<culs::Interface::Properties::IsOnline>> is_online;
 
51
    std::shared_ptr<dbus::Property<culs::Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
33
52
};
34
53
 
35
54
culs::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub<culs::Interface>(connection),
44
63
culss::Interface::Ptr culs::Stub::create_session_for_criteria(const cul::Criteria& criteria)
45
64
{
46
65
    auto op = d->object->transact_method<
47
 
        culs::Interface::CreateSessionForCriteria,
48
 
        culs::Interface::CreateSessionForCriteria::ResultType
49
 
    >(criteria);
 
66
            culs::Interface::CreateSessionForCriteria,
 
67
            culs::Interface::CreateSessionForCriteria::ResultType
 
68
            >(criteria);
50
69
 
51
70
    if (op.is_error())
52
 
        throw std::runtime_error(op.error().print());
 
71
    {
 
72
        std::stringstream ss; ss << __PRETTY_FUNCTION__ << ": " << op.error().print();
 
73
        throw std::runtime_error(ss.str());
 
74
    }
53
75
 
54
76
    return culss::Interface::Ptr(new culss::Stub{d->bus, op.value()});
55
77
}
 
78
 
 
79
core::Property<bool>& culs::Stub::does_satellite_based_positioning()
 
80
{
 
81
    return *d->does_satellite_based_positioning;
 
82
}
 
83
 
 
84
core::Property<bool>& culs::Stub::does_report_cell_and_wifi_ids()
 
85
{
 
86
    return *d->does_report_cell_and_wifi_ids;
 
87
}
 
88
 
 
89
core::Property<bool>& culs::Stub::is_online()
 
90
{
 
91
    return *d->is_online;
 
92
}
 
93
 
 
94
core::Property<std::map<cul::SpaceVehicle::Key, cul::SpaceVehicle>>& culs::Stub::visible_space_vehicles()
 
95
{
 
96
    return *d->visible_space_vehicles;
 
97
}