1 /*
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 
34 typedef void* (getLocationInterface)();
35 
36 namespace android {
37 namespace hardware {
38 namespace gnss {
39 namespace V1_1 {
40 namespace implementation {
41 
42 
AGnssRil(Gnss * gnss)43 AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
44     ENTRY_LOG_CALLFLOW();
45 }
46 
~AGnssRil()47 AGnssRil::~AGnssRil() {
48     ENTRY_LOG_CALLFLOW();
49 }
50 
updateNetworkState(bool connected,NetworkType type,bool)51 Return<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::NetworkInfoDataItemBase::TYPE_UNKNOWN;
61         switch(type)
62         {
63             case IAGnssRil::NetworkType::MOBILE:
64                 typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE;
65                 break;
66             case IAGnssRil::NetworkType::WIFI:
67                 typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI;
68                 break;
69             case IAGnssRil::NetworkType::MMS:
70                 typeout = loc_core::NetworkInfoDataItemBase::TYPE_MMS;
71                 break;
72             case IAGnssRil::NetworkType::SUPL:
73                 typeout = loc_core::NetworkInfoDataItemBase::TYPE_SUPL;
74                 break;
75             case IAGnssRil::NetworkType::DUN:
76                 typeout = loc_core::NetworkInfoDataItemBase::TYPE_DUN;
77                 break;
78             case IAGnssRil::NetworkType::HIPRI:
79                 typeout = loc_core::NetworkInfoDataItemBase::TYPE_HIPRI;
80                 break;
81             case IAGnssRil::NetworkType::WIMAX:
82                 typeout = loc_core::NetworkInfoDataItemBase::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::NetworkInfoDataItemBase::TYPE_BLUETOOTH;
92                             break;
93                         case NetworkType_ETHERNET:
94                             typeout = loc_core::NetworkInfoDataItemBase::TYPE_ETHERNET;
95                             break;
96                         case NetworkType_PROXY:
97                             typeout = loc_core::NetworkInfoDataItemBase::TYPE_PROXY;
98                             break;
99                         default:
100                             typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN;
101                     }
102                 }
103                 break;
104         }
105         mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0);
106     }
107     return true;
108 }
109 
110 }  // namespace implementation
111 }  // namespace V1_1
112 }  // namespace gnss
113 }  // namespace hardware
114 }  // namespace android
115