summaryrefslogtreecommitdiffstats
path: root/gnss/1.0-legacy/GnssConfiguration.cpp
blob: 0c1aa86f8d7f762ca659d0403b8c4f44ad984f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "GnssHAL_GnssConfigurationInterface"

#include <log/log.h>

#include "GnssConfiguration.h"

namespace android {
namespace hardware {
namespace gnss {
namespace V1_0 {
namespace implementation {

GnssConfiguration::GnssConfiguration(const GnssConfigurationInterface* gnssConfigInfc)
    : mGnssConfigIface(gnssConfigInfc) {}

// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
Return<bool> GnssConfiguration::setSuplEs(bool enabled)  {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "SUPL_ES=" + std::to_string(enabled ? 1 : 0) + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());
    return true;
}

Return<bool> GnssConfiguration::setSuplVersion(uint32_t version)  {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "SUPL_VER=" + std::to_string(version) + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());

    return true;
}

Return<bool> GnssConfiguration::setSuplMode(uint8_t mode)  {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "SUPL_MODE=" + std::to_string(mode) + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());
    return true;
}

Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "LPP_PROFILE=" + std::to_string(lppProfile) + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());
    return true;
}

Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "A_GLONASS_POS_PROTOCOL_SELECT=" +
            std::to_string(protocol) + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());
    return true;
}

Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "GPS_LOCK=" + std::to_string(lock) + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());
    return true;
}

Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
    if (mGnssConfigIface == nullptr) {
        ALOGE("%s: GNSS Configuration interface is not available.", __func__);
        return false;
    }

    std::string config = "USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=" + std::to_string(enabled ? 1 : 0)
            + "\n";
    mGnssConfigIface->configuration_update(config.c_str(), config.size());
    return true;
}

}  // namespace implementation
}  // namespace V1_0
}  // namespace gnss
}  // namespace hardware
}  // namespace android