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