AGnssRil.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2017-2019, 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. #define LOG_TAG "LocSvc__AGnssRilInterface"
  21. #include <log_util.h>
  22. #include <dlfcn.h>
  23. #include <sys/types.h>
  24. #include <sys/socket.h>
  25. #include <sys/un.h>
  26. #include <sstream>
  27. #include <string>
  28. #include "Gnss.h"
  29. #include "AGnssRil.h"
  30. #include <DataItemConcreteTypes.h>
  31. typedef void* (getLocationInterface)();
  32. namespace android {
  33. namespace hardware {
  34. namespace gnss {
  35. namespace V2_0 {
  36. namespace implementation {
  37. AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
  38. ENTRY_LOG_CALLFLOW();
  39. }
  40. AGnssRil::~AGnssRil() {
  41. ENTRY_LOG_CALLFLOW();
  42. }
  43. Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) {
  44. ENTRY_LOG_CALLFLOW();
  45. // Extra NetworkTypes not available in IAgnssRil enums
  46. const int NetworkType_BLUETOOTH = 7;
  47. const int NetworkType_ETHERNET = 9;
  48. const int NetworkType_PROXY = 16;
  49. std::string apn("");
  50. // for XTRA
  51. if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
  52. int8_t typeout = loc_core::TYPE_UNKNOWN;
  53. switch(type)
  54. {
  55. case IAGnssRil::NetworkType::MOBILE:
  56. typeout = loc_core::TYPE_MOBILE;
  57. break;
  58. case IAGnssRil::NetworkType::WIFI:
  59. typeout = loc_core::TYPE_WIFI;
  60. break;
  61. case IAGnssRil::NetworkType::MMS:
  62. typeout = loc_core::TYPE_MMS;
  63. break;
  64. case IAGnssRil::NetworkType::SUPL:
  65. typeout = loc_core::TYPE_SUPL;
  66. break;
  67. case IAGnssRil::NetworkType::DUN:
  68. typeout = loc_core::TYPE_DUN;
  69. break;
  70. case IAGnssRil::NetworkType::HIPRI:
  71. typeout = loc_core::TYPE_HIPRI;
  72. break;
  73. case IAGnssRil::NetworkType::WIMAX:
  74. typeout = loc_core::TYPE_WIMAX;
  75. break;
  76. default:
  77. {
  78. int networkType = (int) type;
  79. // Handling network types not available in IAgnssRil
  80. switch(networkType)
  81. {
  82. case NetworkType_BLUETOOTH:
  83. typeout = loc_core::TYPE_BLUETOOTH;
  84. break;
  85. case NetworkType_ETHERNET:
  86. typeout = loc_core::TYPE_ETHERNET;
  87. break;
  88. case NetworkType_PROXY:
  89. typeout = loc_core::TYPE_PROXY;
  90. break;
  91. default:
  92. typeout = loc_core::TYPE_UNKNOWN;
  93. }
  94. }
  95. break;
  96. }
  97. mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn);
  98. }
  99. return true;
  100. }
  101. Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) {
  102. ENTRY_LOG_CALLFLOW();
  103. std::string apn = attributes.apn;
  104. if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) {
  105. int8_t typeout = loc_core::TYPE_UNKNOWN;
  106. bool roaming = false;
  107. if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) {
  108. typeout = loc_core::TYPE_WIFI;
  109. } else {
  110. typeout = loc_core::TYPE_MOBILE;
  111. }
  112. if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) {
  113. roaming = false;
  114. }
  115. LOC_LOGd("apn string received is: %s", apn.c_str());
  116. mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected,
  117. typeout, roaming, (NetworkHandle) attributes.networkHandle, apn);
  118. }
  119. return true;
  120. }
  121. } // namespace implementation
  122. } // namespace V2_0
  123. } // namespace gnss
  124. } // namespace hardware
  125. } // namespace android