blob: 65fb30050b55350c5317bf238e9869b67c132dbe [file] [log] [blame]
Yingjie Wang8c6487a2020-01-07 09:14:39 +08001/*
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"
32#include <DataItemConcreteTypesBase.h>
33
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
58 // for XTRA
59 if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
60 int8_t typeout = loc_core::TYPE_UNKNOWN;
61 switch(type)
62 {
63 case IAGnssRil::NetworkType::MOBILE:
64 typeout = loc_core::TYPE_MOBILE;
65 break;
66 case IAGnssRil::NetworkType::WIFI:
67 typeout = loc_core::TYPE_WIFI;
68 break;
69 case IAGnssRil::NetworkType::MMS:
70 typeout = loc_core::TYPE_MMS;
71 break;
72 case IAGnssRil::NetworkType::SUPL:
73 typeout = loc_core::TYPE_SUPL;
74 break;
75 case IAGnssRil::NetworkType::DUN:
76 typeout = loc_core::TYPE_DUN;
77 break;
78 case IAGnssRil::NetworkType::HIPRI:
79 typeout = loc_core::TYPE_HIPRI;
80 break;
81 case IAGnssRil::NetworkType::WIMAX:
82 typeout = loc_core::TYPE_WIMAX;
83 break;
84 default:
85 {
86 int networkType = (int) type;
87 // Handling network types not available in IAgnssRil
88 switch(networkType)
89 {
90 case NetworkType_BLUETOOTH:
91 typeout = loc_core::TYPE_BLUETOOTH;
92 break;
93 case NetworkType_ETHERNET:
94 typeout = loc_core::TYPE_ETHERNET;
95 break;
96 case NetworkType_PROXY:
97 typeout = loc_core::TYPE_PROXY;
98 break;
99 default:
100 typeout = loc_core::TYPE_UNKNOWN;
101 }
102 }
103 break;
104 }
105 mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0);
106 }
107 return true;
108}
109Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) {
110 ENTRY_LOG_CALLFLOW();
111
112 if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) {
113 int8_t typeout = loc_core::TYPE_UNKNOWN;
114 bool roaming = false;
115 if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) {
116 typeout = loc_core::TYPE_WIFI;
117 } else {
118 typeout = loc_core::TYPE_MOBILE;
119 }
120 if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) {
121 roaming = false;
122 }
123 mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected,
124 typeout, roaming, (NetworkHandle) attributes.networkHandle);
125 }
126 return true;
127}
128
129} // namespace implementation
130} // namespace V2_1
131} // namespace gnss
132} // namespace hardware
133} // namespace android