blob: 9031c064121cba7f9df17bd9caebe945f0024d93 [file] [log] [blame]
Hridya Valsaraju29dc1e02016-10-21 14:41:12 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "GnssHAL_GnssConfigurationInterface"
18
19#include "GnssConfiguration.h"
20
21namespace android {
22namespace hardware {
23namespace gnss {
24namespace V1_0 {
25namespace implementation {
26
27GnssConfiguration::GnssConfiguration(const GnssConfigurationInterface* gnssConfigInfc)
28 : mGnssConfigIface(gnssConfigInfc) {}
29
30// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
31Return<bool> GnssConfiguration::setSuplEs(bool enabled) {
32 if (mGnssConfigIface == nullptr) {
33 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
34 return false;
35 }
36
37 std::string config = "SUPL_ES=" + std::to_string(enabled ? 1 : 0) + "\n";
38 mGnssConfigIface->configuration_update(config.c_str(), config.size());
39 return true;
40}
41
42Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
43 if (mGnssConfigIface == nullptr) {
44 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
45 return false;
46 }
47
48 std::string config = "SUPL_VER=" + std::to_string(version) + "\n";
49 mGnssConfigIface->configuration_update(config.c_str(), config.size());
50
51 return true;
52}
53
54Return<bool> GnssConfiguration::setSuplMode(uint8_t mode) {
55 if (mGnssConfigIface == nullptr) {
56 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
57 return false;
58 }
59
60 std::string config = "SUPL_MODE=" + std::to_string(mode) + "\n";
61 mGnssConfigIface->configuration_update(config.c_str(), config.size());
62 return true;
63}
64
65Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
66 if (mGnssConfigIface == nullptr) {
67 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
68 return false;
69 }
70
71 std::string config = "LPP_PROFILE=" + std::to_string(lppProfile) + "\n";
72 mGnssConfigIface->configuration_update(config.c_str(), config.size());
73 return true;
74}
75
76Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
77 if (mGnssConfigIface == nullptr) {
78 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
79 return false;
80 }
81
82 std::string config = "A_GLONASS_POS_PROTOCOL_SELECT=" +
83 std::to_string(protocol) + "\n";
84 mGnssConfigIface->configuration_update(config.c_str(), config.size());
85 return true;
86}
87
88Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
89 if (mGnssConfigIface == nullptr) {
90 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
91 return false;
92 }
93
94 std::string config = "GPS_LOCK=" + std::to_string(lock) + "\n";
95 mGnssConfigIface->configuration_update(config.c_str(), config.size());
96 return true;
97}
98
99Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
100 if (mGnssConfigIface == nullptr) {
101 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
102 return false;
103 }
104
105 std::string config = "USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=" + std::to_string(enabled ? 1 : 0)
106 + "\n";
107 mGnssConfigIface->configuration_update(config.c_str(), config.size());
108 return true;
109}
110
111} // namespace implementation
112} // namespace V1_0
113} // namespace gnss
114} // namespace hardware
115} // namespace android