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

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/service/permission_manager.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_PERMISSION_MANAGER_H_
19
19
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_
20
20
 
21
 
#include "com/ubuntu/location/channel.h"
22
 
#include "com/ubuntu/location/provider_selection_policy.h"
23
 
 
24
 
#include <functional>
 
21
#include <memory>
25
22
 
26
23
namespace com
27
24
{
29
26
{
30
27
namespace location
31
28
{
 
29
struct Criteria;
32
30
namespace service
33
31
{
 
32
/** @brief Credentials of a remote session. */
34
33
struct Credentials
35
34
{
 
35
    /** @brief The process id of the remote peer. */
36
36
    pid_t pid;
 
37
    /** @brief The user id the remote peer runs under. */
37
38
    uid_t uid;
38
39
};
39
40
 
 
41
/**
 
42
 * @brief The PermissionManager class is an interface to check whether an application
 
43
 * is allowed to access the location services.
 
44
 */
40
45
class PermissionManager
41
46
{
42
47
public:
 
48
    /** Manager pointer type. */
43
49
    typedef std::shared_ptr<PermissionManager> Ptr;
44
50
 
 
51
    /**
 
52
     * @brief The Result enum summarizes the results of a query for permissions.
 
53
     */
45
54
    enum class Result
46
55
    {
47
 
        granted,
48
 
        rejected
 
56
        granted, ///< The app is allowed to access the location service.
 
57
        rejected ///< The app is not allowed to access the location service.
49
58
    };
50
59
 
51
60
    virtual ~PermissionManager() = default;
52
61
    PermissionManager(const PermissionManager&) = delete;
53
62
    PermissionManager& operator=(const PermissionManager&) = delete;
54
63
 
 
64
    /**
 
65
     * @brief Checks whether the app with the given credentials is allowed to access the service for the given criteria.
 
66
     * @param criteria The requirements of the remote peer.
 
67
     * @param credentials The credentials identifying the remote peer.
 
68
     * @return Result::granted if the remote peer is allowed to access the location service, Result::rejected otherwise.
 
69
     */
55
70
    virtual Result check_permission_for_credentials(
56
71
        const Criteria& criteria,
57
72
        const Credentials& credentials) = 0;