blob: e2d594814d95a298fd73e35008e7fc4913c7411b [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"
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 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() )) {
Michael Bestas222c86c2024-07-18 12:36:55 -040061 int8_t typeout = loc_core::TYPE_UNKNOWN;
Michael Bestas3a0209e2023-05-04 01:15:47 +030062 switch(type)
63 {
64 case IAGnssRil::NetworkType::MOBILE:
Michael Bestas222c86c2024-07-18 12:36:55 -040065 typeout = loc_core::TYPE_MOBILE;
Michael Bestas3a0209e2023-05-04 01:15:47 +030066 break;
67 case IAGnssRil::NetworkType::WIFI:
Michael Bestas222c86c2024-07-18 12:36:55 -040068 typeout = loc_core::TYPE_WIFI;
Michael Bestas3a0209e2023-05-04 01:15:47 +030069 break;
70 case IAGnssRil::NetworkType::MMS:
Michael Bestas222c86c2024-07-18 12:36:55 -040071 typeout = loc_core::TYPE_MMS;
Michael Bestas3a0209e2023-05-04 01:15:47 +030072 break;
73 case IAGnssRil::NetworkType::SUPL:
Michael Bestas222c86c2024-07-18 12:36:55 -040074 typeout = loc_core::TYPE_SUPL;
Michael Bestas3a0209e2023-05-04 01:15:47 +030075 break;
76 case IAGnssRil::NetworkType::DUN:
Michael Bestas222c86c2024-07-18 12:36:55 -040077 typeout = loc_core::TYPE_DUN;
Michael Bestas3a0209e2023-05-04 01:15:47 +030078 break;
79 case IAGnssRil::NetworkType::HIPRI:
Michael Bestas222c86c2024-07-18 12:36:55 -040080 typeout = loc_core::TYPE_HIPRI;
Michael Bestas3a0209e2023-05-04 01:15:47 +030081 break;
82 case IAGnssRil::NetworkType::WIMAX:
Michael Bestas222c86c2024-07-18 12:36:55 -040083 typeout = loc_core::TYPE_WIMAX;
Michael Bestas3a0209e2023-05-04 01:15:47 +030084 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:
Michael Bestas222c86c2024-07-18 12:36:55 -040092 typeout = loc_core::TYPE_BLUETOOTH;
Michael Bestas3a0209e2023-05-04 01:15:47 +030093 break;
94 case NetworkType_ETHERNET:
Michael Bestas222c86c2024-07-18 12:36:55 -040095 typeout = loc_core::TYPE_ETHERNET;
Michael Bestas3a0209e2023-05-04 01:15:47 +030096 break;
97 case NetworkType_PROXY:
Michael Bestas222c86c2024-07-18 12:36:55 -040098 typeout = loc_core::TYPE_PROXY;
Michael Bestas3a0209e2023-05-04 01:15:47 +030099 break;
100 default:
Michael Bestas222c86c2024-07-18 12:36:55 -0400101 typeout = loc_core::TYPE_UNKNOWN;
Michael Bestas3a0209e2023-05-04 01:15:47 +0300102 }
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