blob: d7f30eb087ebc5a9613db03df686ae936f7dc44b [file] [log] [blame]
Michael Bestas3a0209e2023-05-04 01:15:47 +03001/*
2 * Copyright (c) 2017-2018, 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"
32#include <DataItemConcreteTypesBase.h>
33
34typedef void* (getLocationInterface)();
35
36namespace android {
37namespace hardware {
38namespace gnss {
39namespace V1_0 {
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::NetworkInfoDataItemBase::TYPE_UNKNOWN;
62 switch(type)
63 {
64 case IAGnssRil::NetworkType::MOBILE:
65 typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE;
66 break;
67 case IAGnssRil::NetworkType::WIFI:
68 typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI;
69 break;
70 case IAGnssRil::NetworkType::MMS:
71 typeout = loc_core::NetworkInfoDataItemBase::TYPE_MMS;
72 break;
73 case IAGnssRil::NetworkType::SUPL:
74 typeout = loc_core::NetworkInfoDataItemBase::TYPE_SUPL;
75 break;
76 case IAGnssRil::NetworkType::DUN:
77 typeout = loc_core::NetworkInfoDataItemBase::TYPE_DUN;
78 break;
79 case IAGnssRil::NetworkType::HIPRI:
80 typeout = loc_core::NetworkInfoDataItemBase::TYPE_HIPRI;
81 break;
82 case IAGnssRil::NetworkType::WIMAX:
83 typeout = loc_core::NetworkInfoDataItemBase::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::NetworkInfoDataItemBase::TYPE_BLUETOOTH;
93 break;
94 case NetworkType_ETHERNET:
95 typeout = loc_core::NetworkInfoDataItemBase::TYPE_ETHERNET;
96 break;
97 case NetworkType_PROXY:
98 typeout = loc_core::NetworkInfoDataItemBase::TYPE_PROXY;
99 break;
100 default:
101 typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN;
102 }
103 }
104 break;
105 }
106 mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn);
107 }
108 return true;
109}
110
111} // namespace implementation
112} // namespace V1_0
113} // namespace gnss
114} // namespace hardware
115} // namespace android