blob: 49b98f66f6f425064afbe88814e7286e84924854 [file] [log] [blame]
Michael Bestas3a0209e2023-05-04 01:15:47 +03001/*
2 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
3 * Not a Contribution
4 */
5/*
6 * Copyright (C) 2016 The Android Open Source Project
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#define LOG_TAG "LocSvc__AGnssRilInterface"
22
23#include <log_util.h>
24#include <dlfcn.h>
25#include <sys/types.h>
26#include <sys/socket.h>
27#include <sys/un.h>
28#include <sstream>
29#include <string>
30#include "Gnss.h"
31#include "AGnssRil.h"
Michael Bestas222c86c2024-07-18 12:36:55 -040032#include <DataItemConcreteTypes.h>
Michael Bestas3a0209e2023-05-04 01:15:47 +030033
34typedef void* (getLocationInterface)();
35
36namespace android {
37namespace hardware {
38namespace gnss {
39namespace V2_1 {
40namespace implementation {
41
42
43AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
44 ENTRY_LOG_CALLFLOW();
45}
46
47AGnssRil::~AGnssRil() {
48 ENTRY_LOG_CALLFLOW();
49}
50
51Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) {
52 ENTRY_LOG_CALLFLOW();
53 // Extra NetworkTypes not available in IAgnssRil enums
54 const int NetworkType_BLUETOOTH = 7;
55 const int NetworkType_ETHERNET = 9;
56 const int NetworkType_PROXY = 16;
57 std::string apn("");
58
59 // for XTRA
60 if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
61 int8_t typeout = loc_core::TYPE_UNKNOWN;
62 switch(type)
63 {
64 case IAGnssRil::NetworkType::MOBILE:
65 typeout = loc_core::TYPE_MOBILE;
66 break;
67 case IAGnssRil::NetworkType::WIFI:
68 typeout = loc_core::TYPE_WIFI;
69 break;
70 case IAGnssRil::NetworkType::MMS:
71 typeout = loc_core::TYPE_MMS;
72 break;
73 case IAGnssRil::NetworkType::SUPL:
74 typeout = loc_core::TYPE_SUPL;
75 break;
76 case IAGnssRil::NetworkType::DUN:
77 typeout = loc_core::TYPE_DUN;
78 break;
79 case IAGnssRil::NetworkType::HIPRI:
80 typeout = loc_core::TYPE_HIPRI;
81 break;
82 case IAGnssRil::NetworkType::WIMAX:
83 typeout = loc_core::TYPE_WIMAX;
84 break;
85 default:
86 {
87 int networkType = (int) type;
88 // Handling network types not available in IAgnssRil
89 switch(networkType)
90 {
91 case NetworkType_BLUETOOTH:
92 typeout = loc_core::TYPE_BLUETOOTH;
93 break;
94 case NetworkType_ETHERNET:
95 typeout = loc_core::TYPE_ETHERNET;
96 break;
97 case NetworkType_PROXY:
98 typeout = loc_core::TYPE_PROXY;
99 break;
100 default:
101 typeout = loc_core::TYPE_UNKNOWN;
102 }
103 }
104 break;
105 }
106 mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn);
107 }
108 return true;
109}
110Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) {
111 ENTRY_LOG_CALLFLOW();
112 std::string apn = attributes.apn;
113 if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) {
114 int8_t typeout = loc_core::TYPE_UNKNOWN;
115 bool roaming = false;
116 if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) {
117 typeout = loc_core::TYPE_WIFI;
118 } else {
119 typeout = loc_core::TYPE_MOBILE;
120 }
121 if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) {
122 roaming = false;
123 }
124 LOC_LOGd("apn string received is: %s", apn.c_str());
125 mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected,
126 typeout, roaming, (NetworkHandle) attributes.networkHandle, apn);
127 }
128 return true;
129}
130
131} // namespace implementation
132} // namespace V2_1
133} // namespace gnss
134} // namespace hardware
135} // namespace android