react-native-nitro-background-geolocation 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/NitroBackgroundGeolocation.podspec +29 -0
  2. package/android/CMakeLists.txt +24 -0
  3. package/android/build.gradle +133 -0
  4. package/android/src/main/AndroidManifest.xml +65 -0
  5. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/ConfigMapper.kt +332 -0
  7. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/HeadlessTaskRegistry.kt +23 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/HeadlessTaskService.kt +66 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/NitroBackgroundGeolocation.kt +538 -0
  10. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/NitroBackgroundGeolocationPackage.kt +22 -0
  11. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/ReactNativeHeadlessTaskRunner.kt +62 -0
  12. package/android/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +542 -0
  13. package/android/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +59 -0
  14. package/android/src/main/java/com/marianhello/bgloc/Config.java +652 -0
  15. package/android/src/main/java/com/marianhello/bgloc/ConnectivityListener.java +5 -0
  16. package/android/src/main/java/com/marianhello/bgloc/HttpPostService.java +168 -0
  17. package/android/src/main/java/com/marianhello/bgloc/LocationManager.java +138 -0
  18. package/android/src/main/java/com/marianhello/bgloc/PluginDelegate.java +19 -0
  19. package/android/src/main/java/com/marianhello/bgloc/PluginException.java +38 -0
  20. package/android/src/main/java/com/marianhello/bgloc/PostLocationTask.java +186 -0
  21. package/android/src/main/java/com/marianhello/bgloc/ResourceResolver.java +55 -0
  22. package/android/src/main/java/com/marianhello/bgloc/data/AbstractLocationTemplate.java +69 -0
  23. package/android/src/main/java/com/marianhello/bgloc/data/ArrayListLocationTemplate.java +88 -0
  24. package/android/src/main/java/com/marianhello/bgloc/data/BackgroundActivity.java +108 -0
  25. package/android/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +994 -0
  26. package/android/src/main/java/com/marianhello/bgloc/data/ConfigurationDAO.java +13 -0
  27. package/android/src/main/java/com/marianhello/bgloc/data/DAOFactory.java +17 -0
  28. package/android/src/main/java/com/marianhello/bgloc/data/HashMapLocationTemplate.java +82 -0
  29. package/android/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +22 -0
  30. package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplate.java +12 -0
  31. package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +65 -0
  32. package/android/src/main/java/com/marianhello/bgloc/data/LocationTransform.java +19 -0
  33. package/android/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +395 -0
  34. package/android/src/main/java/com/marianhello/bgloc/data/provider/LocationContentProvider.java +321 -0
  35. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +76 -0
  36. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +160 -0
  37. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +112 -0
  38. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +506 -0
  39. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +151 -0
  40. package/android/src/main/java/com/marianhello/bgloc/headless/AbstractTaskRunner.java +15 -0
  41. package/android/src/main/java/com/marianhello/bgloc/headless/ActivityTask.java +48 -0
  42. package/android/src/main/java/com/marianhello/bgloc/headless/JsCallback.java +10 -0
  43. package/android/src/main/java/com/marianhello/bgloc/headless/LocationTask.java +61 -0
  44. package/android/src/main/java/com/marianhello/bgloc/headless/StationaryTask.java +25 -0
  45. package/android/src/main/java/com/marianhello/bgloc/headless/Task.java +8 -0
  46. package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunner.java +5 -0
  47. package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunnerFactory.java +8 -0
  48. package/android/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +171 -0
  49. package/android/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +280 -0
  50. package/android/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +586 -0
  51. package/android/src/main/java/com/marianhello/bgloc/provider/LocationProvider.java +32 -0
  52. package/android/src/main/java/com/marianhello/bgloc/provider/LocationProviderFactory.java +47 -0
  53. package/android/src/main/java/com/marianhello/bgloc/provider/ProviderDelegate.java +12 -0
  54. package/android/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +142 -0
  55. package/android/src/main/java/com/marianhello/bgloc/service/LocationService.java +17 -0
  56. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +760 -0
  57. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfo.java +6 -0
  58. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfoImpl.java +41 -0
  59. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java +203 -0
  60. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +140 -0
  61. package/android/src/main/java/com/marianhello/bgloc/sync/AccountHelper.java +39 -0
  62. package/android/src/main/java/com/marianhello/bgloc/sync/Authenticator.java +68 -0
  63. package/android/src/main/java/com/marianhello/bgloc/sync/AuthenticatorService.java +28 -0
  64. package/android/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +246 -0
  65. package/android/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java +148 -0
  66. package/android/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +233 -0
  67. package/android/src/main/java/com/marianhello/bgloc/sync/SyncService.java +68 -0
  68. package/android/src/main/java/com/marianhello/logging/DBLogReader.java +203 -0
  69. package/android/src/main/java/com/marianhello/logging/LogEntry.java +99 -0
  70. package/android/src/main/java/com/marianhello/logging/LoggerManager.java +70 -0
  71. package/android/src/main/java/com/marianhello/logging/UncaughtExceptionLogger.java +36 -0
  72. package/android/src/main/java/com/marianhello/utils/CloneHelper.java +22 -0
  73. package/android/src/main/java/com/marianhello/utils/Convert.java +56 -0
  74. package/android/src/main/java/com/marianhello/utils/TextUtils.java +72 -0
  75. package/android/src/main/java/com/marianhello/utils/ToneGenerator.java +68 -0
  76. package/android/src/main/java/org/apache/commons/io/Charsets.java +153 -0
  77. package/android/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +344 -0
  78. package/android/src/main/java/org/chromium/content/browser/ThreadUtils.java +134 -0
  79. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlExpression.java +398 -0
  80. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlSelectStatement.java +671 -0
  81. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlStatement.java +29 -0
  82. package/android/src/main/java/ru/andremoniy/utils/TextUtils.java +61 -0
  83. package/android/src/main/res/values/strings.xml +6 -0
  84. package/android/src/main/res/xml/authenticator.xml +7 -0
  85. package/android/src/main/res/xml/syncadapter.xml +9 -0
  86. package/app.plugin.js +64 -0
  87. package/ios/NitroBackgroundGeolocation.swift +719 -0
  88. package/ios/NitroBackgroundGeolocationBootstrap.m +98 -0
  89. package/ios/common/BackgroundGeolocation/CocoaLumberjack.h +1945 -0
  90. package/ios/common/BackgroundGeolocation/CocoaLumberjack.m +5255 -0
  91. package/ios/common/BackgroundGeolocation/FMDB.h +2357 -0
  92. package/ios/common/BackgroundGeolocation/FMDB.m +2672 -0
  93. package/ios/common/BackgroundGeolocation/FMDBLogger.h +42 -0
  94. package/ios/common/BackgroundGeolocation/FMDBLogger.m +264 -0
  95. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.h +41 -0
  96. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.m +68 -0
  97. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager+Internal.h +33 -0
  98. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.h +178 -0
  99. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.m +1025 -0
  100. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.h +103 -0
  101. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.m +238 -0
  102. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequestDefines.h +163 -0
  103. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.h +39 -0
  104. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.m +37 -0
  105. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.h +51 -0
  106. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.m +53 -0
  107. package/ios/common/BackgroundGeolocation/MAURActivity.h +23 -0
  108. package/ios/common/BackgroundGeolocation/MAURActivity.m +52 -0
  109. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.h +18 -0
  110. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +202 -0
  111. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +62 -0
  112. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +650 -0
  113. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +34 -0
  114. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +184 -0
  115. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.h +25 -0
  116. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.m +105 -0
  117. package/ios/common/BackgroundGeolocation/MAURConfig.h +74 -0
  118. package/ios/common/BackgroundGeolocation/MAURConfig.m +485 -0
  119. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +49 -0
  120. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +51 -0
  121. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.h +20 -0
  122. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +523 -0
  123. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.h +17 -0
  124. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +97 -0
  125. package/ios/common/BackgroundGeolocation/MAURLocation.h +59 -0
  126. package/ios/common/BackgroundGeolocation/MAURLocation.m +349 -0
  127. package/ios/common/BackgroundGeolocation/MAURLocationContract.h +34 -0
  128. package/ios/common/BackgroundGeolocation/MAURLocationContract.m +35 -0
  129. package/ios/common/BackgroundGeolocation/MAURLocationManager.h +53 -0
  130. package/ios/common/BackgroundGeolocation/MAURLocationManager.m +308 -0
  131. package/ios/common/BackgroundGeolocation/MAURLogReader.h +26 -0
  132. package/ios/common/BackgroundGeolocation/MAURLogReader.m +122 -0
  133. package/ios/common/BackgroundGeolocation/MAURLogging.h +19 -0
  134. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +40 -0
  135. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +218 -0
  136. package/ios/common/BackgroundGeolocation/MAURProviderDelegate.h +52 -0
  137. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.h +18 -0
  138. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +129 -0
  139. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.h +26 -0
  140. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +278 -0
  141. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.h +57 -0
  142. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.m +93 -0
  143. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +38 -0
  144. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +380 -0
  145. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.h +32 -0
  146. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.m +276 -0
  147. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.h +20 -0
  148. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.m +62 -0
  149. package/ios/common/BackgroundGeolocation/Reachability.h +102 -0
  150. package/ios/common/BackgroundGeolocation/Reachability.m +474 -0
  151. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.h +80 -0
  152. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.m +147 -0
  153. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.h +30 -0
  154. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.m +42 -0
  155. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.h +99 -0
  156. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.m +327 -0
  157. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.h +44 -0
  158. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.m +94 -0
  159. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.h +55 -0
  160. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.m +47 -0
  161. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlDataManipulationCommand.h +27 -0
  162. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.h +250 -0
  163. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.m +259 -0
  164. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.h +360 -0
  165. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.m +427 -0
  166. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlStatement.h +37 -0
  167. package/lib/module/NitroBackgroundGeolocation.nitro.js +172 -0
  168. package/lib/module/NitroBackgroundGeolocation.nitro.js.map +1 -0
  169. package/lib/module/headless.js +72 -0
  170. package/lib/module/headless.js.map +1 -0
  171. package/lib/module/index.js +60 -0
  172. package/lib/module/index.js.map +1 -0
  173. package/lib/module/package.json +1 -0
  174. package/lib/typescript/package.json +1 -0
  175. package/lib/typescript/src/NitroBackgroundGeolocation.nitro.d.ts +616 -0
  176. package/lib/typescript/src/NitroBackgroundGeolocation.nitro.d.ts.map +1 -0
  177. package/lib/typescript/src/headless.d.ts +40 -0
  178. package/lib/typescript/src/headless.d.ts.map +1 -0
  179. package/lib/typescript/src/index.d.ts +8 -0
  180. package/lib/typescript/src/index.d.ts.map +1 -0
  181. package/nitro.json +23 -0
  182. package/nitrogen/generated/android/c++/JActivity.hpp +61 -0
  183. package/nitrogen/generated/android/c++/JAuthorizationStatus.hpp +61 -0
  184. package/nitrogen/generated/android/c++/JBackgroundGeolocationError.hpp +61 -0
  185. package/nitrogen/generated/android/c++/JConfigureOptions.hpp +179 -0
  186. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  187. package/nitrogen/generated/android/c++/JFunc_void_Activity.hpp +78 -0
  188. package/nitrogen/generated/android/c++/JFunc_void_AuthorizationStatus.hpp +77 -0
  189. package/nitrogen/generated/android/c++/JFunc_void_BackgroundGeolocationError.hpp +78 -0
  190. package/nitrogen/generated/android/c++/JFunc_void_Location.hpp +78 -0
  191. package/nitrogen/generated/android/c++/JFunc_void_StationaryLocation.hpp +78 -0
  192. package/nitrogen/generated/android/c++/JHybridNitroBackgroundGeolocationSpec.cpp +530 -0
  193. package/nitrogen/generated/android/c++/JHybridNitroBackgroundGeolocationSpec.hpp +90 -0
  194. package/nitrogen/generated/android/c++/JLocation.hpp +105 -0
  195. package/nitrogen/generated/android/c++/JLocationAccuracy.hpp +64 -0
  196. package/nitrogen/generated/android/c++/JLocationOptions.hpp +65 -0
  197. package/nitrogen/generated/android/c++/JLocationProvider.hpp +61 -0
  198. package/nitrogen/generated/android/c++/JLogEntry.hpp +73 -0
  199. package/nitrogen/generated/android/c++/JNativeLogLevel.hpp +67 -0
  200. package/nitrogen/generated/android/c++/JServiceStatus.hpp +66 -0
  201. package/nitrogen/generated/android/c++/JStationaryLocation.hpp +109 -0
  202. package/nitrogen/generated/android/c++/JVariant_NullType_AnyMap.cpp +26 -0
  203. package/nitrogen/generated/android/c++/JVariant_NullType_AnyMap.hpp +71 -0
  204. package/nitrogen/generated/android/c++/JVariant_NullType_Boolean.cpp +26 -0
  205. package/nitrogen/generated/android/c++/JVariant_NullType_Boolean.hpp +69 -0
  206. package/nitrogen/generated/android/c++/JVariant_NullType_Double.cpp +26 -0
  207. package/nitrogen/generated/android/c++/JVariant_NullType_Double.hpp +69 -0
  208. package/nitrogen/generated/android/c++/JVariant_NullType_LocationAccuracy.cpp +26 -0
  209. package/nitrogen/generated/android/c++/JVariant_NullType_LocationAccuracy.hpp +71 -0
  210. package/nitrogen/generated/android/c++/JVariant_NullType_LocationProvider.cpp +26 -0
  211. package/nitrogen/generated/android/c++/JVariant_NullType_LocationProvider.hpp +71 -0
  212. package/nitrogen/generated/android/c++/JVariant_NullType_Map_String__String_.cpp +33 -0
  213. package/nitrogen/generated/android/c++/JVariant_NullType_Map_String__String_.hpp +77 -0
  214. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  215. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  216. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Activity.kt +56 -0
  217. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/AuthorizationStatus.kt +24 -0
  218. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/BackgroundGeolocationError.kt +56 -0
  219. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/ConfigureOptions.kt +182 -0
  220. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void.kt +80 -0
  221. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_Activity.kt +80 -0
  222. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_AuthorizationStatus.kt +80 -0
  223. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_BackgroundGeolocationError.kt +80 -0
  224. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_Location.kt +80 -0
  225. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_StationaryLocation.kt +80 -0
  226. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/HybridNitroBackgroundGeolocationSpec.kt +218 -0
  227. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Location.kt +111 -0
  228. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LocationAccuracy.kt +25 -0
  229. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LocationOptions.kt +61 -0
  230. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LocationProvider.kt +24 -0
  231. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LogEntry.kt +71 -0
  232. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/NativeLogLevel.kt +26 -0
  233. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/ServiceStatus.kt +61 -0
  234. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/StationaryLocation.kt +116 -0
  235. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_AnyMap.kt +63 -0
  236. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_Boolean.kt +62 -0
  237. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_Double.kt +62 -0
  238. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_LocationAccuracy.kt +62 -0
  239. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_LocationProvider.kt +62 -0
  240. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_Map_String__String_.kt +62 -0
  241. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_String.kt +62 -0
  242. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/nitrobackgroundgeolocationOnLoad.kt +35 -0
  243. package/nitrogen/generated/android/nitrobackgroundgeolocation+autolinking.cmake +88 -0
  244. package/nitrogen/generated/android/nitrobackgroundgeolocation+autolinking.gradle +27 -0
  245. package/nitrogen/generated/android/nitrobackgroundgeolocationOnLoad.cpp +66 -0
  246. package/nitrogen/generated/android/nitrobackgroundgeolocationOnLoad.hpp +34 -0
  247. package/nitrogen/generated/ios/NitroBackgroundGeolocation+autolinking.rb +62 -0
  248. package/nitrogen/generated/ios/NitroBackgroundGeolocation-Swift-Cxx-Bridge.cpp +129 -0
  249. package/nitrogen/generated/ios/NitroBackgroundGeolocation-Swift-Cxx-Bridge.hpp +911 -0
  250. package/nitrogen/generated/ios/NitroBackgroundGeolocation-Swift-Cxx-Umbrella.hpp +88 -0
  251. package/nitrogen/generated/ios/NitroBackgroundGeolocationAutolinking.mm +33 -0
  252. package/nitrogen/generated/ios/NitroBackgroundGeolocationAutolinking.swift +26 -0
  253. package/nitrogen/generated/ios/c++/HybridNitroBackgroundGeolocationSpecSwift.cpp +11 -0
  254. package/nitrogen/generated/ios/c++/HybridNitroBackgroundGeolocationSpecSwift.hpp +335 -0
  255. package/nitrogen/generated/ios/swift/Activity.swift +34 -0
  256. package/nitrogen/generated/ios/swift/AuthorizationStatus.swift +44 -0
  257. package/nitrogen/generated/ios/swift/BackgroundGeolocationError.swift +34 -0
  258. package/nitrogen/generated/ios/swift/ConfigureOptions.swift +1037 -0
  259. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  260. package/nitrogen/generated/ios/swift/Func_void_Activity.swift +46 -0
  261. package/nitrogen/generated/ios/swift/Func_void_AuthorizationStatus.swift +46 -0
  262. package/nitrogen/generated/ios/swift/Func_void_BackgroundGeolocationError.swift +46 -0
  263. package/nitrogen/generated/ios/swift/Func_void_ConfigureOptions.swift +46 -0
  264. package/nitrogen/generated/ios/swift/Func_void_Location.swift +46 -0
  265. package/nitrogen/generated/ios/swift/Func_void_ServiceStatus.swift +46 -0
  266. package/nitrogen/generated/ios/swift/Func_void_StationaryLocation.swift +46 -0
  267. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  268. package/nitrogen/generated/ios/swift/Func_void_std__optional_StationaryLocation_.swift +46 -0
  269. package/nitrogen/generated/ios/swift/Func_void_std__vector_Location_.swift +46 -0
  270. package/nitrogen/generated/ios/swift/Func_void_std__vector_LogEntry_.swift +46 -0
  271. package/nitrogen/generated/ios/swift/HybridNitroBackgroundGeolocationSpec.swift +82 -0
  272. package/nitrogen/generated/ios/swift/HybridNitroBackgroundGeolocationSpec_cxx.swift +675 -0
  273. package/nitrogen/generated/ios/swift/Location.swift +89 -0
  274. package/nitrogen/generated/ios/swift/LocationAccuracy.swift +48 -0
  275. package/nitrogen/generated/ios/swift/LocationOptions.swift +78 -0
  276. package/nitrogen/generated/ios/swift/LocationProvider.swift +44 -0
  277. package/nitrogen/generated/ios/swift/LogEntry.swift +49 -0
  278. package/nitrogen/generated/ios/swift/NativeLogLevel.swift +52 -0
  279. package/nitrogen/generated/ios/swift/ServiceStatus.swift +39 -0
  280. package/nitrogen/generated/ios/swift/StationaryLocation.swift +94 -0
  281. package/nitrogen/generated/ios/swift/Variant_NullType_AnyMap.swift +30 -0
  282. package/nitrogen/generated/ios/swift/Variant_NullType_Bool.swift +30 -0
  283. package/nitrogen/generated/ios/swift/Variant_NullType_Dictionary_String__String_.swift +30 -0
  284. package/nitrogen/generated/ios/swift/Variant_NullType_Double.swift +30 -0
  285. package/nitrogen/generated/ios/swift/Variant_NullType_LocationAccuracy.swift +30 -0
  286. package/nitrogen/generated/ios/swift/Variant_NullType_LocationProvider.swift +30 -0
  287. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +30 -0
  288. package/nitrogen/generated/shared/c++/Activity.hpp +87 -0
  289. package/nitrogen/generated/shared/c++/AuthorizationStatus.hpp +63 -0
  290. package/nitrogen/generated/shared/c++/BackgroundGeolocationError.hpp +87 -0
  291. package/nitrogen/generated/shared/c++/ConfigureOptions.hpp +197 -0
  292. package/nitrogen/generated/shared/c++/HybridNitroBackgroundGeolocationSpec.cpp +48 -0
  293. package/nitrogen/generated/shared/c++/HybridNitroBackgroundGeolocationSpec.hpp +121 -0
  294. package/nitrogen/generated/shared/c++/Location.hpp +131 -0
  295. package/nitrogen/generated/shared/c++/LocationAccuracy.hpp +69 -0
  296. package/nitrogen/generated/shared/c++/LocationOptions.hpp +91 -0
  297. package/nitrogen/generated/shared/c++/LocationProvider.hpp +63 -0
  298. package/nitrogen/generated/shared/c++/LogEntry.hpp +99 -0
  299. package/nitrogen/generated/shared/c++/NativeLogLevel.hpp +65 -0
  300. package/nitrogen/generated/shared/c++/ServiceStatus.hpp +92 -0
  301. package/nitrogen/generated/shared/c++/StationaryLocation.hpp +135 -0
  302. package/package.json +112 -0
  303. package/react-native.config.js +10 -0
  304. package/src/NitroBackgroundGeolocation.nitro.ts +656 -0
  305. package/src/headless.ts +91 -0
  306. package/src/index.tsx +100 -0
@@ -0,0 +1,994 @@
1
+ package com.marianhello.bgloc.data;
2
+
3
+ import android.content.ContentValues;
4
+ import android.database.Cursor;
5
+ import android.location.Location;
6
+ import android.os.Build;
7
+ import android.os.Bundle;
8
+ import android.os.Parcel;
9
+ import android.os.Parcelable;
10
+ import androidx.core.util.TimeUtils;
11
+
12
+ import com.marianhello.bgloc.data.sqlite.SQLiteLocationContract.LocationEntry;
13
+
14
+ import org.json.JSONException;
15
+ import org.json.JSONObject;
16
+
17
+ public class BackgroundLocation implements Parcelable {
18
+ public static final int DELETED = 0;
19
+ public static final int POST_PENDING = 1;
20
+ public static final int SYNC_PENDING = 2;
21
+
22
+ private Long locationId = null;
23
+ private Integer locationProvider = null;
24
+ private Long batchStartMillis = null;
25
+ private String provider;
26
+ private double latitude = 0.0;
27
+ private double longitude = 0.0;
28
+ private long time = 0;
29
+ private long elapsedRealtimeNanos = 0;
30
+ private float accuracy = 0.0f;
31
+ private float verticalAccuracy = 0.0f;
32
+ private float speed = 0.0f;
33
+ private float bearing = 0.0f;
34
+ private double altitude = 0.0f;
35
+ private float radius = 0.0f;
36
+ private boolean hasAccuracy = false;
37
+ private boolean hasVerticalAccuracy = false;
38
+ private boolean hasAltitude = false;
39
+ private boolean hasSpeed = false;
40
+ private boolean hasBearing = false;
41
+ private boolean hasRadius = false;
42
+ private int mockFlags = 0x0000;
43
+ private int status = POST_PENDING;
44
+ private Bundle extras = null;
45
+
46
+ private static final long TWO_MINUTES_IN_NANOS = 1000000000L * 60 * 2;
47
+
48
+ public BackgroundLocation() {}
49
+
50
+ public BackgroundLocation(String provider) {
51
+ this.provider = provider;
52
+ }
53
+
54
+ /**
55
+ * Construct BackgroundLocation by copying properties from android Location.
56
+ * @param location
57
+ */
58
+ @Deprecated
59
+ public BackgroundLocation(Location location) {
60
+ this(BackgroundLocation.fromLocation(location));
61
+ }
62
+
63
+ @Deprecated
64
+ public BackgroundLocation(Integer locationProvider, Location location) {
65
+ this(location);
66
+ this.locationProvider = locationProvider;
67
+ }
68
+
69
+ /**
70
+ * Construct stationary BackgroundLocation.
71
+ * @param locationProvider
72
+ * @param location
73
+ * @param radius radius of stationary region
74
+ */
75
+ @Deprecated
76
+ public BackgroundLocation(Integer locationProvider, Location location, float radius) {
77
+ this(locationProvider, location);
78
+ setRadius(radius);
79
+ }
80
+
81
+ /**
82
+ * Construct a new Location object that is copied from an existing one.
83
+ * @param location
84
+ */
85
+ public BackgroundLocation(BackgroundLocation l) {
86
+ locationId = l.locationId;
87
+ locationProvider = l.locationProvider;
88
+ batchStartMillis = l.batchStartMillis;
89
+ provider = l.provider;
90
+ latitude = l.latitude;
91
+ longitude = l.longitude;
92
+ time = l.time;
93
+ elapsedRealtimeNanos = l.elapsedRealtimeNanos;
94
+ accuracy = l.accuracy;
95
+ verticalAccuracy = l.verticalAccuracy;
96
+ speed = l.speed;
97
+ bearing = l.bearing;
98
+ altitude = l.altitude;
99
+ radius = l.radius;
100
+ hasAccuracy = l.hasAccuracy;
101
+ hasVerticalAccuracy = l.hasVerticalAccuracy;
102
+ hasAltitude = l.hasAltitude;
103
+ hasSpeed = l.hasSpeed;
104
+ hasBearing = l.hasBearing;
105
+ hasRadius = l.hasRadius;
106
+ mockFlags = l.mockFlags;
107
+ status = l.status;
108
+ extras = (l.extras == null) ? null : new Bundle(l.extras);
109
+ }
110
+
111
+ private static BackgroundLocation fromParcel(Parcel in) {
112
+ BackgroundLocation l = new BackgroundLocation();
113
+
114
+ l.locationId = in.readLong();
115
+ l.locationProvider = in.readInt();
116
+ l.batchStartMillis = in.readLong();
117
+ l.provider = in.readString();
118
+ l.latitude = in.readDouble();
119
+ l.longitude = in.readDouble();
120
+ l.time = in.readLong();
121
+ l.elapsedRealtimeNanos = in.readLong();
122
+ l.accuracy = in.readFloat();
123
+ l.verticalAccuracy = in.readFloat();
124
+ l.speed = in.readFloat();
125
+ l.bearing = in.readFloat();
126
+ l.altitude = in.readDouble();
127
+ l.radius = in.readFloat();
128
+ l.hasAccuracy = in.readInt() != 0;
129
+ l.hasVerticalAccuracy = in.readInt() != 0;
130
+ l.hasAltitude = in.readInt() != 0;
131
+ l.hasSpeed = in.readInt() != 0;
132
+ l.hasBearing = in.readInt() != 0;
133
+ l.hasRadius = in.readInt() != 0;
134
+ l.mockFlags = in.readInt();
135
+ l.status = in.readInt();
136
+ l.extras = in.readBundle();
137
+
138
+ return l;
139
+ }
140
+
141
+ public static BackgroundLocation fromLocation(Location location) {
142
+ BackgroundLocation l = new BackgroundLocation();
143
+
144
+ l.provider = location.getProvider();
145
+ l.latitude = location.getLatitude();
146
+ l.longitude = location.getLongitude();
147
+ l.time = location.getTime();
148
+ l.accuracy = location.getAccuracy();
149
+ l.speed = location.getSpeed();
150
+ l.bearing = location.getBearing();
151
+ l.altitude = location.getAltitude();
152
+ l.hasAccuracy = location.hasAccuracy();
153
+ l.hasAltitude = location.hasAltitude();
154
+ l.hasSpeed = location.hasSpeed();
155
+ l.hasBearing = location.hasBearing();
156
+ l.extras = location.getExtras();
157
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
158
+ l.elapsedRealtimeNanos = location.getElapsedRealtimeNanos();
159
+ }
160
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
161
+ l.setIsFromMockProvider(location.isFromMockProvider());
162
+ }
163
+
164
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
165
+ l.verticalAccuracy = location.getVerticalAccuracyMeters();
166
+ l.hasVerticalAccuracy = location.hasVerticalAccuracy();
167
+ }
168
+
169
+ return l;
170
+ }
171
+
172
+ /**
173
+ * Create a new Location from a cursor
174
+ *
175
+ * @param c the cursor
176
+ * @return the note
177
+ */
178
+ public static BackgroundLocation fromCursor(Cursor c) {
179
+ BackgroundLocation l = new BackgroundLocation();
180
+
181
+ l.setProvider(c.getString(c.getColumnIndex(LocationEntry.COLUMN_NAME_PROVIDER)));
182
+ l.setTime(c.getLong(c.getColumnIndex(LocationEntry.COLUMN_NAME_TIME)));
183
+ if (c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_HAS_ACCURACY)) == 1) {
184
+ l.setAccuracy(c.getFloat(c.getColumnIndex(LocationEntry.COLUMN_NAME_ACCURACY)));
185
+ }
186
+ if (c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_HAS_VERTICAL_ACCURACY)) == 1) {
187
+ l.setVerticalAccuracy(c.getFloat(c.getColumnIndex(LocationEntry.COLUMN_NAME_VERTICAL_ACCURACY)));
188
+ }
189
+ if (c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_HAS_SPEED)) == 1) {
190
+ l.setSpeed(c.getFloat(c.getColumnIndex(LocationEntry.COLUMN_NAME_SPEED)));
191
+ }
192
+ if (c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_HAS_BEARING)) == 1) {
193
+ l.setBearing(c.getFloat(c.getColumnIndex(LocationEntry.COLUMN_NAME_BEARING)));
194
+ }
195
+ if (c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_HAS_ALTITUDE)) == 1) {
196
+ l.setAltitude(c.getDouble(c.getColumnIndex(LocationEntry.COLUMN_NAME_ALTITUDE)));
197
+ }
198
+ if (c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_HAS_RADIUS)) == 1) {
199
+ l.setRadius(c.getFloat(c.getColumnIndex(LocationEntry.COLUMN_NAME_RADIUS)));
200
+ }
201
+ l.setLatitude(c.getDouble(c.getColumnIndex(LocationEntry.COLUMN_NAME_LATITUDE)));
202
+ l.setLongitude(c.getDouble(c.getColumnIndex(LocationEntry.COLUMN_NAME_LONGITUDE)));
203
+ l.setLocationProvider(c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_LOCATION_PROVIDER)));
204
+ l.setBatchStartMillis(c.getLong(c.getColumnIndex(LocationEntry.COLUMN_NAME_BATCH_START_MILLIS)));
205
+ l.setStatus(c.getInt(c.getColumnIndex(LocationEntry.COLUMN_NAME_STATUS)));
206
+ l.setLocationId(c.getLong(c.getColumnIndex(LocationEntry._ID)));
207
+ l.setMockFlags(c.getInt((c.getColumnIndex(LocationEntry.COLUMN_NAME_MOCK_FLAGS))));
208
+
209
+ return l;
210
+ }
211
+
212
+ @Override
213
+ public int describeContents() {
214
+ return 0;
215
+ }
216
+
217
+ @Override
218
+ public void writeToParcel(Parcel dest, int flags) {
219
+ dest.writeLong(locationId);
220
+ dest.writeInt(locationProvider);
221
+ dest.writeLong(batchStartMillis);
222
+ dest.writeString(provider);
223
+ dest.writeDouble(latitude);
224
+ dest.writeDouble(longitude);
225
+ dest.writeLong(time);
226
+ dest.writeLong(elapsedRealtimeNanos);
227
+ dest.writeFloat(accuracy);
228
+ dest.writeFloat(verticalAccuracy);
229
+ dest.writeFloat(speed);
230
+ dest.writeFloat(bearing);
231
+ dest.writeDouble(altitude);
232
+ dest.writeFloat(radius);
233
+ dest.writeInt(hasAccuracy ? 1 : 0);
234
+ dest.writeInt(hasVerticalAccuracy ? 1 : 0);
235
+ dest.writeInt(hasAltitude ? 1 : 0);
236
+ dest.writeInt(hasSpeed ? 1 : 0);
237
+ dest.writeInt(hasBearing ? 1 : 0);
238
+ dest.writeInt(hasRadius ? 1 : 0);
239
+ dest.writeInt(mockFlags);
240
+ dest.writeInt(status);
241
+ dest.writeBundle(extras);
242
+ }
243
+
244
+ public static final Parcelable.Creator<BackgroundLocation> CREATOR
245
+ = new Parcelable.Creator<BackgroundLocation>() {
246
+ public BackgroundLocation createFromParcel(Parcel in) {
247
+ return BackgroundLocation.fromParcel(in);
248
+ }
249
+ public BackgroundLocation[] newArray(int size) {
250
+ return new BackgroundLocation[size];
251
+ }
252
+ };
253
+
254
+ public BackgroundLocation makeClone() {
255
+ return new BackgroundLocation(this);
256
+ }
257
+
258
+ /**
259
+ * Returns locationId if location was stored in db.
260
+ * @return locationId or null
261
+ */
262
+ public Long getLocationId() {
263
+ return locationId;
264
+ }
265
+
266
+
267
+ /**
268
+ * Sets locationId
269
+ * used when location was persisted into db and returned db id is used locationId
270
+ * @param locationId
271
+ */
272
+ public void setLocationId(Long locationId) {
273
+ this.locationId = locationId;
274
+ }
275
+
276
+ /**
277
+ * Returns location provider that generated this location.
278
+ * @return location provider id
279
+ */
280
+ public Integer getLocationProvider() {
281
+ return locationProvider;
282
+ }
283
+
284
+ /**
285
+ * Sets the location provider that generated this location.
286
+ * @param locationProvider
287
+ */
288
+ public void setLocationProvider(Integer locationProvider) {
289
+ this.locationProvider = locationProvider;
290
+ }
291
+
292
+ /**
293
+ * Returns batch start time in milliseconds when location is being synced with remote server.
294
+ * @return batch run time or null
295
+ */
296
+ public Long getBatchStartMillis() {
297
+ return batchStartMillis;
298
+ }
299
+
300
+ /**
301
+ * Sets batch start time
302
+ * @param batch run time in milliseconds
303
+ */
304
+ public void setBatchStartMillis(Long batchStartMillis) {
305
+ this.batchStartMillis = batchStartMillis;
306
+ }
307
+
308
+ /**
309
+ * Returns the name of the provider that generated this fix.
310
+ * @return the provider, or null if it has not been set
311
+ */
312
+ public String getProvider() {
313
+ return provider;
314
+ }
315
+
316
+ /**
317
+ * Sets the name of the provider that generated this fix.
318
+ */
319
+ public void setProvider(String provider) {
320
+ this.provider = provider;
321
+ }
322
+
323
+ /**
324
+ * Get the altitude if available, in meters above the WGS 84 reference
325
+ * ellipsoid.
326
+ *
327
+ * <p>If this location does not have an altitude then 0.0 is returned.
328
+ */
329
+ public double getLatitude() {
330
+ return latitude;
331
+ }
332
+
333
+ /**
334
+ * Set the altitude, in meters above the WGS 84 reference ellipsoid.
335
+ *
336
+ * <p>Following this call {@link #hasAltitude} will return true.
337
+ */
338
+ public void setLatitude(double latitude) {
339
+ this.latitude = latitude;
340
+ }
341
+
342
+ /**
343
+ * Get the longitude, in degrees.
344
+ *
345
+ * <p>All locations generated by the {@link LocationManager}
346
+ * will have a valid longitude.
347
+ */
348
+ public double getLongitude() {
349
+ return longitude;
350
+ }
351
+
352
+ /**
353
+ * Set the longitude, in degrees.
354
+ */
355
+ public void setLongitude(double longitude) {
356
+ this.longitude = longitude;
357
+ }
358
+
359
+
360
+ /**
361
+ * Return the UTC time of this fix, in milliseconds since January 1, 1970.
362
+ *
363
+ * <p>Note that the UTC time on a device is not monotonic: it
364
+ * can jump forwards or backwards unpredictably. So always use
365
+ * {@link #getElapsedRealtimeNanos} when calculating time deltas.
366
+ *
367
+ * <p>On the other hand, {@link #getTime} is useful for presenting
368
+ * a human readable time to the user, or for carefully comparing
369
+ * location fixes across reboot or across devices.
370
+ *
371
+ * <p>All locations generated by the {@link LocationManager}
372
+ * are guaranteed to have a valid UTC time, however remember that
373
+ * the system time may have changed since the location was generated.
374
+ *
375
+ * @return time of fix, in milliseconds since January 1, 1970.
376
+ */
377
+ public long getTime() {
378
+ return time;
379
+ }
380
+
381
+ /**
382
+ * Set the UTC time of this fix, in milliseconds since January 1,
383
+ * 1970.
384
+ *
385
+ * @param time UTC time of this fix, in milliseconds since January 1, 1970
386
+ */
387
+ public void setTime(long time) {
388
+ this.time = time;
389
+ }
390
+
391
+ /**
392
+ * Return the time of this fix, in elapsed real-time since system boot.
393
+ *
394
+ * <p>This value can be reliably compared to
395
+ * {@link android.os.SystemClock#elapsedRealtimeNanos},
396
+ * to calculate the age of a fix and to compare Location fixes. This
397
+ * is reliable because elapsed real-time is guaranteed monotonic for
398
+ * each system boot and continues to increment even when the system
399
+ * is in deep sleep (unlike {@link #getTime}.
400
+ *
401
+ * <p>All locations generated by the {@link LocationManager}
402
+ * are guaranteed to have a valid elapsed real-time.
403
+ *
404
+ * @return elapsed real-time of fix, in nanoseconds since system boot.
405
+ */
406
+ public long getElapsedRealtimeNanos() {
407
+ return elapsedRealtimeNanos;
408
+ }
409
+
410
+ /**
411
+ * Set the time of this fix, in elapsed real-time since system boot.
412
+ *
413
+ * @param time elapsed real-time of fix, in nanoseconds since system boot.
414
+ */
415
+ public void setElapsedRealtimeNanos(long elapsedRealtimeNanos) {
416
+ this.elapsedRealtimeNanos = elapsedRealtimeNanos;
417
+ }
418
+
419
+ /**
420
+ * Get the estimated accuracy of this location, in meters.
421
+ *
422
+ * <p>We define accuracy as the radius of 68% confidence. In other
423
+ * words, if you draw a circle centered at this location's
424
+ * latitude and longitude, and with a radius equal to the accuracy,
425
+ * then there is a 68% probability that the true location is inside
426
+ * the circle.
427
+ *
428
+ * <p>In statistical terms, it is assumed that location errors
429
+ * are random with a normal distribution, so the 68% confidence circle
430
+ * represents one standard deviation. Note that in practice, location
431
+ * errors do not always follow such a simple distribution.
432
+ *
433
+ * <p>This accuracy estimation is only concerned with horizontal
434
+ * accuracy, and does not indicate the accuracy of bearing,
435
+ * velocity or altitude if those are included in this Location.
436
+ *
437
+ * <p>If this location does not have an accuracy, then 0.0 is returned.
438
+ * All locations generated by the {@link LocationManager} include
439
+ * an accuracy.
440
+ */
441
+ public float getAccuracy() {
442
+ return accuracy;
443
+ }
444
+
445
+ /**
446
+ * Set the estimated accuracy of this location, meters.
447
+ *
448
+ * <p>See {@link #getAccuracy} for the definition of accuracy.
449
+ *
450
+ * <p>Following this call {@link #hasAccuracy} will return true.
451
+ */
452
+ public void setAccuracy(float accuracy) {
453
+ this.accuracy = accuracy;
454
+ this.hasAccuracy = true;
455
+ }
456
+
457
+ public float getVerticalAccuracy() {
458
+ return verticalAccuracy;
459
+ }
460
+
461
+ public void setVerticalAccuracy(float accuracy) {
462
+ this.verticalAccuracy = accuracy;
463
+ this.hasVerticalAccuracy = true;
464
+ }
465
+
466
+ /**
467
+ * Get the speed if it is available, in meters/second over ground.
468
+ *
469
+ * <p>If this location does not have a speed then 0.0 is returned.
470
+ */
471
+ public float getSpeed() {
472
+ return speed;
473
+ }
474
+
475
+ /**
476
+ * Set the speed, in meters/second over ground.
477
+ *
478
+ * <p>Following this call {@link #hasSpeed} will return true.
479
+ */
480
+ public void setSpeed(float speed) {
481
+ this.speed = speed;
482
+ this.hasSpeed = true;
483
+ }
484
+
485
+ /**
486
+ * Get the bearing, in degrees.
487
+ *
488
+ * <p>Bearing is the horizontal direction of travel of this device,
489
+ * and is not related to the device orientation. It is guaranteed to
490
+ * be in the range (0.0, 360.0] if the device has a bearing.
491
+ *
492
+ * <p>If this location does not have a bearing then 0.0 is returned.
493
+ */
494
+ public float getBearing() {
495
+ return bearing;
496
+ }
497
+
498
+ /**
499
+ * Set the bearing, in degrees.
500
+ *
501
+ * <p>Bearing is the horizontal direction of travel of this device,
502
+ * and is not related to the device orientation.
503
+ *
504
+ * <p>The input will be wrapped into the range (0.0, 360.0].
505
+ */
506
+ public void setBearing(float bearing) {
507
+ this.bearing = bearing;
508
+ this.hasBearing = true;
509
+ }
510
+
511
+ /**
512
+ * Get the altitude if available, in meters above the WGS 84 reference
513
+ * ellipsoid.
514
+ *
515
+ * <p>If this location does not have an altitude then 0.0 is returned.
516
+ */
517
+ public double getAltitude() {
518
+ return altitude;
519
+ }
520
+
521
+ /**
522
+ * Set the altitude, in meters above the WGS 84 reference ellipsoid.
523
+ *
524
+ * <p>Following this call {@link #hasAltitude} will return true.
525
+ */
526
+ public void setAltitude(double altitude) {
527
+ this.altitude = altitude;
528
+ this.hasAltitude = true;
529
+ }
530
+
531
+ /**
532
+ * Return radius of stationary region.
533
+ */
534
+ public float getRadius() {
535
+ return radius;
536
+ }
537
+
538
+ /**
539
+ * Sets radius of stationary region.
540
+ */
541
+ public void setRadius(float radius) {
542
+ this.radius = radius;
543
+ this.hasRadius = true;
544
+ }
545
+
546
+ /**
547
+ * True if this location has an accuracy.
548
+ *
549
+ * <p>All locations generated by the {@link LocationManager} have an
550
+ * accuracy.
551
+ */
552
+ public boolean hasAccuracy() {
553
+ return hasAccuracy;
554
+ }
555
+
556
+ public boolean hasVerticalAccuracy() {
557
+ return hasVerticalAccuracy;
558
+ }
559
+
560
+ /**
561
+ * True if this location has an altitude.
562
+ */
563
+ public boolean hasAltitude() {
564
+ return hasAltitude;
565
+ }
566
+
567
+ /**
568
+ * True if this location has a speed.
569
+ */
570
+ public boolean hasSpeed() {
571
+ return hasSpeed;
572
+ }
573
+
574
+ /**
575
+ * True if this location has a bearing.
576
+ */
577
+ public boolean hasBearing() {
578
+ return hasBearing;
579
+ }
580
+
581
+ /**
582
+ * True if this location has a radius.
583
+ */
584
+ public boolean hasRadius() {
585
+ return hasRadius;
586
+ }
587
+
588
+ /**
589
+ * Mock flags is 4-bit representation of mock status
590
+ *
591
+ * xxx0 - isFromMockProvider is false
592
+ * xxx1 - isFromMockProvider is true
593
+ * xx0x - hasIsFromMockProvider is false
594
+ * xx1x - hasIsFromMockProvider is true
595
+ * x0xx - areMockLocationsEnabled is false
596
+ * x1xx - areMockLocationsEnabled is true
597
+ * 0xxx - hasMockLocationsEnabled is false
598
+ * 1xxx - hasMockLocationsEnabled is true
599
+ *
600
+ * @return mock flags
601
+ */
602
+ public int getMockFlags() {
603
+ return mockFlags;
604
+ }
605
+
606
+ public void setMockFlags(int mockFlags) {
607
+ this.mockFlags = mockFlags;
608
+ }
609
+
610
+ /**
611
+ * Return true if method setIsFromMockProvider was called on location instance
612
+ * @return true indicates that result from isFromMockProvider method is valid
613
+ */
614
+ public boolean hasIsFromMockProvider() {
615
+ return ((mockFlags & 0x0002) >> 1) == 1;
616
+ }
617
+
618
+ /**
619
+ * Returns true if the Location came from a mock provider.
620
+ * Always check hasIsFromMockProvider() before this method
621
+ *
622
+ * @return true if this Location came from a mock provider, false otherwise
623
+ */
624
+ public boolean isFromMockProvider() {
625
+ return (mockFlags & 0x0001) == 1;
626
+ }
627
+
628
+ /**
629
+ * Method should be called to indicate that location was recorded by mock provider
630
+ * If this method was called hasIsFromMockProvider method will always return true
631
+ *
632
+ * @param isFromMockProvider
633
+ */
634
+ public void setIsFromMockProvider(boolean isFromMockProvider) {
635
+ mockFlags |= isFromMockProvider ? 0x0003 : 0x0002;
636
+ }
637
+
638
+ /**
639
+ * Return true if method setMockLocationsEnabled was called on location instance
640
+ * @return true indicates that result from areMockLocationsEnabled method is valid
641
+ */
642
+ public boolean hasMockLocationsEnabled() {
643
+ return ((mockFlags & 0x0008) >> 3) == 1;
644
+ }
645
+
646
+ /**
647
+ * Returns true if mock locations were enabled
648
+ * Always check hasMockLocationsEnabled() before this method
649
+ *
650
+ * @return true if mock locations were enabled
651
+ */
652
+ public boolean areMockLocationsEnabled() {
653
+ return ((mockFlags & 0x0004) >> 2) == 1;
654
+ }
655
+
656
+ /**
657
+ * Method should be called when mock locations were detect in settings
658
+ * If this method was called hasMockLocationsEnabled method will always return true
659
+ *
660
+ * @param mockLocationsEnabled
661
+ */
662
+ public void setMockLocationsEnabled(Boolean mockLocationsEnabled) {
663
+ mockFlags |= mockLocationsEnabled ? 0x000C : 0x0008;
664
+ }
665
+
666
+ /**
667
+ * Returns status of location. Can be one of:
668
+ * <ul>
669
+ * <li>{@value #DELETED}</li>
670
+ * <li>{@value #POST_PENDING}</li>
671
+ * <li>{@value #SYNC_PENDING}</li>
672
+ * </ul>
673
+ * @return status
674
+ */
675
+ public int getStatus() {
676
+ return status;
677
+ }
678
+
679
+ /**
680
+ * Sets status of location. Can be one of:
681
+ * <ul>
682
+ * <li>{@value #DELETED}</li>
683
+ * <li>{@value #POST_PENDING}</li>
684
+ * <li>{@value #SYNC_PENDING}</li>
685
+ * </ul>
686
+ * @param status
687
+ */
688
+ public void setStatus(int status) {
689
+ this.status = status;
690
+ }
691
+
692
+ /**
693
+ * Returns additional provider-specific information about the
694
+ * location fix as a Bundle. The keys and values are determined
695
+ * by the provider. If no additional information is available,
696
+ * null is returned.
697
+ *
698
+ * <p> A number of common key/value pairs are listed
699
+ * below. Providers that use any of the keys on this list must
700
+ * provide the corresponding value as described below.
701
+ *
702
+ * <ul>
703
+ * <li> satellites - the number of satellites used to derive the fix
704
+ * </ul>
705
+ */
706
+ public Bundle getExtras() {
707
+ return extras;
708
+ }
709
+
710
+ /**
711
+ * Sets the extra information associated with this fix to the
712
+ * given Bundle.
713
+ */
714
+ public void setExtras(Bundle extras) {
715
+ this.extras = extras;
716
+ }
717
+
718
+ /**
719
+ * Return android Location instance
720
+ *
721
+ * @return android.location.Location instance
722
+ */
723
+ public Location getLocation() {
724
+ Location l = new Location(provider);
725
+ l.setLatitude(latitude);
726
+ l.setLongitude(longitude);
727
+ l.setTime(time);
728
+ if (hasAccuracy) l.setAccuracy(accuracy);
729
+
730
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
731
+ if (hasVerticalAccuracy)
732
+ l.setVerticalAccuracyMeters(verticalAccuracy);
733
+ }
734
+
735
+ if (hasAltitude) l.setAltitude(altitude);
736
+ if (hasSpeed) l.setSpeed(speed);
737
+ if (hasBearing) l.setBearing(bearing);
738
+ l.setExtras(extras);
739
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
740
+ l.setElapsedRealtimeNanos(elapsedRealtimeNanos);
741
+ }
742
+
743
+ return l;
744
+ }
745
+
746
+ /** Determines whether one Location reading is better than the current Location fix
747
+ *
748
+ * Origin: https://developer.android.com/guide/topics/location/strategies.html
749
+ *
750
+ * @param location The new Location that you want to evaluate
751
+ * @param currentBestLocation The current Location fix, to which you want to compare the new one
752
+ */
753
+ public static boolean isBetterLocation(BackgroundLocation location, BackgroundLocation currentBestLocation) {
754
+ if (location == null) {
755
+ return false;
756
+ }
757
+ if (currentBestLocation == null) {
758
+ // A new location is always better than no location
759
+ return true;
760
+ }
761
+
762
+ long timeDeltaInNanos = 0;
763
+ // Check whether the new location fix is newer or older
764
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
765
+ // because getTime is not monotonic
766
+ timeDeltaInNanos = location.getElapsedRealtimeNanos() - currentBestLocation.getElapsedRealtimeNanos();
767
+ } else {
768
+ // unfortunately there is no other way for pre JELLY_BEAN_MR1 (API Level 17)
769
+ timeDeltaInNanos = (location.getTime() - currentBestLocation.getTime()) * 1000000;
770
+ }
771
+
772
+ boolean isSignificantlyNewer = timeDeltaInNanos > TWO_MINUTES_IN_NANOS;
773
+ boolean isSignificantlyOlder = timeDeltaInNanos < -TWO_MINUTES_IN_NANOS;
774
+ boolean isNewer = timeDeltaInNanos > 0;
775
+
776
+ // If it's been more than two minutes since the current location, use the new location
777
+ // because the user has likely moved
778
+ if (isSignificantlyNewer) {
779
+ return true;
780
+ // If the new location is more than two minutes older, it must be worse
781
+ } else if (isSignificantlyOlder) {
782
+ return false;
783
+ }
784
+
785
+ // Check whether the new location fix is more or less accurate
786
+ int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
787
+ boolean isLessAccurate = accuracyDelta > 0;
788
+ boolean isMoreAccurate = accuracyDelta < 0;
789
+ boolean isSignificantlyLessAccurate = accuracyDelta > 200;
790
+
791
+ // Check if the old and new location are from the same provider
792
+ boolean isFromSameProvider = isSameProvider(location.getProvider(),
793
+ currentBestLocation.getProvider());
794
+
795
+ // Determine location quality using a combination of timeliness and accuracy
796
+ if (isMoreAccurate) {
797
+ return true;
798
+ } else if (isNewer && !isLessAccurate) {
799
+ return true;
800
+ } else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
801
+ return true;
802
+ }
803
+ return false;
804
+ }
805
+
806
+ /**
807
+ * Check if given location is better that instance
808
+ * @param location to compare is android Location
809
+ * @return true if location is better and false if not
810
+ */
811
+ public boolean isBetterLocationThan(Location location) {
812
+ if (location == null) {
813
+ return true;
814
+ }
815
+ return !isBetterLocation(new BackgroundLocation(location), this);
816
+ }
817
+
818
+ /**
819
+ * Check if given location is better that instance
820
+ * @param location to compare
821
+ * @return true if location is better and false if not
822
+ */
823
+ public boolean isBetterLocationThan(BackgroundLocation location) {
824
+ if (location == null) {
825
+ return true;
826
+ }
827
+ return !isBetterLocation(location, this);
828
+ }
829
+
830
+ /** Checks whether two providers are the same */
831
+ private static boolean isSameProvider(String provider1, String provider2) {
832
+ if (provider1 == null) {
833
+ return provider2 == null;
834
+ }
835
+ return provider1.equals(provider2);
836
+ }
837
+
838
+ @Override
839
+ public String toString () {
840
+ StringBuilder s = new StringBuilder();
841
+ s.append("BGLocation[").append(provider);
842
+ s.append(String.format(" %.6f,%.6f", latitude, longitude));
843
+ s.append(" id=").append(locationId);
844
+ if (hasAccuracy) {
845
+ s.append(String.format(" acc=%.0f", accuracy));
846
+ } else {
847
+ s.append(" acc=???");
848
+ }
849
+
850
+ if (hasVerticalAccuracy) {
851
+ s.append(String.format(" altAcc=%.0f", verticalAccuracy));
852
+ }
853
+ else {
854
+ s.append(" altAcc=???");
855
+ }
856
+
857
+ if (time == 0) {
858
+ s.append(" t=?!?");
859
+ } else {
860
+ s.append(" t=").append(time);
861
+ }
862
+ if (elapsedRealtimeNanos == 0) {
863
+ s.append(" et=?!?");
864
+ } else {
865
+ s.append(" et=");
866
+ TimeUtils.formatDuration(elapsedRealtimeNanos / 1000000L, s);
867
+ }
868
+ if (hasAltitude) s.append(" alt=").append(altitude);
869
+ if (hasSpeed) s.append(" vel=").append(speed);
870
+ if (hasBearing) s.append(" bear=").append(bearing);
871
+ if (hasRadius) s.append(" radius=").append(radius);
872
+ if (isFromMockProvider()) s.append(" mock");
873
+ if (areMockLocationsEnabled()) s.append(" mocksEnabled");
874
+ if (extras != null) {
875
+ s.append(" {").append(extras).append('}');
876
+ }
877
+ s.append(" locprov=").append(locationProvider);
878
+ s.append("]");
879
+
880
+ return s.toString();
881
+ }
882
+
883
+ /**
884
+ * Returns location as JSON object.
885
+ * @throws JSONException
886
+ */
887
+ public JSONObject toJSONObject() throws JSONException {
888
+ JSONObject json = new JSONObject();
889
+ json.put("provider", provider);
890
+ json.put("locationProvider", locationProvider);
891
+ json.put("time", time);
892
+ json.put("latitude", latitude);
893
+ json.put("longitude", longitude);
894
+ if (hasAccuracy) json.put("accuracy", accuracy);
895
+ if (hasVerticalAccuracy) json.put("altitudeAccuracy", verticalAccuracy);
896
+ if (hasSpeed) json.put("speed", speed);
897
+ if (hasAltitude) json.put("altitude", altitude);
898
+ if (hasBearing) json.put("bearing", bearing);
899
+ if (hasRadius) json.put("radius", radius);
900
+ if (hasIsFromMockProvider()) json.put("isFromMockProvider", isFromMockProvider());
901
+ if (hasMockLocationsEnabled()) json.put("mockLocationsEnabled", areMockLocationsEnabled());
902
+
903
+ return json;
904
+ }
905
+
906
+ /**
907
+ * Returns location as JSON object containing location id
908
+ * Note: Location id is not unique and is usually being recycled when
909
+ * maximum number of locations is stored.
910
+ *
911
+ * @throws JSONException
912
+ */
913
+ public JSONObject toJSONObjectWithId() throws JSONException {
914
+ JSONObject json = toJSONObject();
915
+ json.put("id", locationId);
916
+ return json;
917
+ }
918
+
919
+ /**
920
+ * Return the contentvalues for this record
921
+ */
922
+ public ContentValues toContentValues() {
923
+ ContentValues values = new ContentValues();
924
+ //values.put(LocationEntry._ID, locationId);
925
+ values.put(LocationEntry.COLUMN_NAME_TIME, time);
926
+ values.put(LocationEntry.COLUMN_NAME_ACCURACY, accuracy);
927
+ values.put(LocationEntry.COLUMN_NAME_VERTICAL_ACCURACY, verticalAccuracy);
928
+ values.put(LocationEntry.COLUMN_NAME_SPEED, speed);
929
+ values.put(LocationEntry.COLUMN_NAME_BEARING, bearing);
930
+ values.put(LocationEntry.COLUMN_NAME_ALTITUDE, altitude);
931
+ values.put(LocationEntry.COLUMN_NAME_LATITUDE, latitude);
932
+ values.put(LocationEntry.COLUMN_NAME_LONGITUDE, longitude);
933
+ values.put(LocationEntry.COLUMN_NAME_RADIUS, radius);
934
+ values.put(LocationEntry.COLUMN_NAME_HAS_ACCURACY, hasAccuracy);
935
+ values.put(LocationEntry.COLUMN_NAME_HAS_VERTICAL_ACCURACY, hasVerticalAccuracy);
936
+ values.put(LocationEntry.COLUMN_NAME_HAS_SPEED, hasSpeed);
937
+ values.put(LocationEntry.COLUMN_NAME_HAS_BEARING, hasBearing);
938
+ values.put(LocationEntry.COLUMN_NAME_HAS_ALTITUDE, hasAltitude);
939
+ values.put(LocationEntry.COLUMN_NAME_HAS_RADIUS, hasRadius);
940
+ values.put(LocationEntry.COLUMN_NAME_PROVIDER, provider);
941
+ values.put(LocationEntry.COLUMN_NAME_LOCATION_PROVIDER, locationProvider);
942
+ values.put(LocationEntry.COLUMN_NAME_STATUS, status);
943
+ values.put(LocationEntry.COLUMN_NAME_BATCH_START_MILLIS, batchStartMillis);
944
+ values.put(LocationEntry.COLUMN_NAME_MOCK_FLAGS, mockFlags);
945
+ return values;
946
+ }
947
+
948
+ public Object getValueForKey(String key) {
949
+ if ("@id".equals(key)) {
950
+ return locationId;
951
+ }
952
+ if ("@provider".equals(key)) {
953
+ return provider;
954
+ }
955
+ if ("@locationProvider".equals(key)) {
956
+ return locationProvider;
957
+ }
958
+ if ("@time".equals(key)) {
959
+ return time;
960
+ }
961
+ if ("@latitude".equals(key)) {
962
+ return latitude;
963
+ }
964
+ if ("@longitude".equals(key)) {
965
+ return longitude;
966
+ }
967
+ if ("@accuracy".equals(key)) {
968
+ return hasAccuracy ? accuracy : JSONObject.NULL;
969
+ }
970
+ if ("@altitudeAccuracy".equals(key)) {
971
+ return hasVerticalAccuracy ? verticalAccuracy : JSONObject.NULL;
972
+ }
973
+ if ("@speed".equals(key)) {
974
+ return hasSpeed ? speed : JSONObject.NULL;
975
+ }
976
+ if ("@altitude".equals(key)) {
977
+ return hasAltitude ? altitude : JSONObject.NULL;
978
+ }
979
+ if ("@bearing".equals(key)) {
980
+ return hasBearing ? bearing : JSONObject.NULL;
981
+ }
982
+ if ("@radius".equals(key)) {
983
+ return hasRadius ? radius : JSONObject.NULL;
984
+ }
985
+ if ("@isFromMockProvider".equals(key)) {
986
+ return hasIsFromMockProvider() ? isFromMockProvider() : JSONObject.NULL;
987
+ }
988
+ if ("@mockLocationsEnabled".equals(key)) {
989
+ return hasMockLocationsEnabled() ? areMockLocationsEnabled() : JSONObject.NULL;
990
+ }
991
+
992
+ return null;
993
+ }
994
+ }