blob: 0c1aa86f8d7f762ca659d0403b8c4f44ad984f5b [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"
Mark Salyzyn3ff52602017-01-10 10:16:48 -080018
19#include <log/log.h>
Hridya Valsaraju29dc1e02016-10-21 14:41:12 -070020
21#include "GnssConfiguration.h"
22
23namespace android {
24namespace hardware {
25namespace gnss {
26namespace V1_0 {
27namespace implementation {
28
29GnssConfiguration::GnssConfiguration(const GnssConfigurationInterface* gnssConfigInfc)
30 : mGnssConfigIface(gnssConfigInfc) {}
31
32// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
33Return<bool> GnssConfiguration::setSuplEs(bool enabled) {
34 if (mGnssConfigIface == nullptr) {
35 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
36 return false;
37 }
38
39 std::string config = "SUPL_ES=" + std::to_string(enabled ? 1 : 0) + "\n";
40 mGnssConfigIface->configuration_update(config.c_str(), config.size());
41 return true;
42}
43
44Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
45 if (mGnssConfigIface == nullptr) {
46 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
47 return false;
48 }
49
50 std::string config = "SUPL_VER=" + std::to_string(version) + "\n";
51 mGnssConfigIface->configuration_update(config.c_str(), config.size());
52
53 return true;
54}
55
56Return<bool> GnssConfiguration::setSuplMode(uint8_t mode) {
57 if (mGnssConfigIface == nullptr) {
58 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
59 return false;
60 }
61
62 std::string config = "SUPL_MODE=" + std::to_string(mode) + "\n";
63 mGnssConfigIface->configuration_update(config.c_str(), config.size());
64 return true;
65}
66
67Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
68 if (mGnssConfigIface == nullptr) {
69 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
70 return false;
71 }
72
73 std::string config = "LPP_PROFILE=" + std::to_string(lppProfile) + "\n";
74 mGnssConfigIface->configuration_update(config.c_str(), config.size());
75 return true;
76}
77
78Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
79 if (mGnssConfigIface == nullptr) {
80 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
81 return false;
82 }
83
84 std::string config = "A_GLONASS_POS_PROTOCOL_SELECT=" +
85 std::to_string(protocol) + "\n";
86 mGnssConfigIface->configuration_update(config.c_str(), config.size());
87 return true;
88}
89
90Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
91 if (mGnssConfigIface == nullptr) {
92 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
93 return false;
94 }
95
96 std::string config = "GPS_LOCK=" + std::to_string(lock) + "\n";
97 mGnssConfigIface->configuration_update(config.c_str(), config.size());
98 return true;
99}
100
101Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
102 if (mGnssConfigIface == nullptr) {
103 ALOGE("%s: GNSS Configuration interface is not available.", __func__);
104 return false;
105 }
106
107 std::string config = "USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=" + std::to_string(enabled ? 1 : 0)
108 + "\n";
109 mGnssConfigIface->configuration_update(config.c_str(), config.size());
110 return true;
111}
112
113} // namespace implementation
114} // namespace V1_0
115} // namespace gnss
116} // namespace hardware
117} // namespace android