@josuelmm/cordova-background-geolocation 2.3.5

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 (239) hide show
  1. package/.npmignore +23 -0
  2. package/CHANGELOG.md +787 -0
  3. package/CONTRIBUTORS.md +15 -0
  4. package/HISTORY.md +734 -0
  5. package/LICENSE +191 -0
  6. package/README.md +125 -0
  7. package/RELEASE.MD +5 -0
  8. package/android/CDVBackgroundGeolocation/src/main/AndroidManifest.xml +23 -0
  9. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/HandlerWrapper.java +18 -0
  10. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/JavaScriptInterface.java +22 -0
  11. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/JsEvaluator.java +133 -0
  12. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/JsFunctionCallFormatter.java +37 -0
  13. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/WebViewWrapper.java +71 -0
  14. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/interfaces/CallJavaResultInterface.java +8 -0
  15. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/interfaces/HandlerWrapperInterface.java +5 -0
  16. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/interfaces/JsCallback.java +10 -0
  17. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/interfaces/JsEvaluatorInterface.java +18 -0
  18. package/android/CDVBackgroundGeolocation/src/main/java/com/evgenii/jsevaluator/interfaces/WebViewWrapperInterface.java +14 -0
  19. package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/ConfigMapper.java +148 -0
  20. package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/PluginRegistry.java +25 -0
  21. package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/headless/JsEvaluatorTaskRunner.java +53 -0
  22. package/android/CDVBackgroundGeolocation/src/main/java/com/tenforwardconsulting/bgloc/cordova/BackgroundGeolocationPlugin.java +603 -0
  23. package/android/CDVBackgroundGeolocation/src/main/res/values/strings.xml +4 -0
  24. package/android/CDVBackgroundGeolocation/src/test/java/com/marianhello/ConfigMapperTest.java +208 -0
  25. package/android/common/src/androidTest/java/com/marianhello/bgloc/BackgroundGeolocationFacadeTest.java +45 -0
  26. package/android/common/src/androidTest/java/com/marianhello/bgloc/BatchManagerTest.java +570 -0
  27. package/android/common/src/androidTest/java/com/marianhello/bgloc/ConfigTest.java +76 -0
  28. package/android/common/src/androidTest/java/com/marianhello/bgloc/ContentProviderLocationDAOTest.java +437 -0
  29. package/android/common/src/androidTest/java/com/marianhello/bgloc/DBLogReaderTest.java +95 -0
  30. package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationContentProviderTest.java +159 -0
  31. package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationServiceProxyTest.java +161 -0
  32. package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationServiceTest.java +247 -0
  33. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteConfigurationDAOTest.java +200 -0
  34. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteLocationDAOTest.java +457 -0
  35. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteLocationDAOThreadTest.java +96 -0
  36. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteOpenHelperTest.java +225 -0
  37. package/android/common/src/androidTest/java/com/marianhello/bgloc/TestPluginDelegate.java +46 -0
  38. package/android/common/src/androidTest/java/com/marianhello/bgloc/TestResourceResolver.java +14 -0
  39. package/android/common/src/androidTest/java/com/marianhello/bgloc/provider/MockLocationProvider.java +50 -0
  40. package/android/common/src/androidTest/java/com/marianhello/bgloc/provider/TestLocationProviderFactory.java +17 -0
  41. package/android/common/src/androidTest/java/com/marianhello/bgloc/sqlite/SQLiteOpenHelper10.java +92 -0
  42. package/android/common/src/androidTest/java/com/marianhello/bgloc/test/LocationProviderTestCase.java +107 -0
  43. package/android/common/src/androidTest/java/com/marianhello/bgloc/test/TestConstants.java +5 -0
  44. package/android/common/src/main/AndroidManifest.xml +72 -0
  45. package/android/common/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +523 -0
  46. package/android/common/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +59 -0
  47. package/android/common/src/main/java/com/marianhello/bgloc/Config.java +652 -0
  48. package/android/common/src/main/java/com/marianhello/bgloc/ConnectivityListener.java +5 -0
  49. package/android/common/src/main/java/com/marianhello/bgloc/HttpPostService.java +224 -0
  50. package/android/common/src/main/java/com/marianhello/bgloc/LocationManager.java +138 -0
  51. package/android/common/src/main/java/com/marianhello/bgloc/PluginDelegate.java +19 -0
  52. package/android/common/src/main/java/com/marianhello/bgloc/PluginException.java +38 -0
  53. package/android/common/src/main/java/com/marianhello/bgloc/PostLocationTask.java +188 -0
  54. package/android/common/src/main/java/com/marianhello/bgloc/ResourceResolver.java +55 -0
  55. package/android/common/src/main/java/com/marianhello/bgloc/data/AbstractLocationTemplate.java +69 -0
  56. package/android/common/src/main/java/com/marianhello/bgloc/data/ArrayListLocationTemplate.java +88 -0
  57. package/android/common/src/main/java/com/marianhello/bgloc/data/BackgroundActivity.java +108 -0
  58. package/android/common/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +994 -0
  59. package/android/common/src/main/java/com/marianhello/bgloc/data/ConfigurationDAO.java +13 -0
  60. package/android/common/src/main/java/com/marianhello/bgloc/data/DAOFactory.java +17 -0
  61. package/android/common/src/main/java/com/marianhello/bgloc/data/HashMapLocationTemplate.java +82 -0
  62. package/android/common/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +22 -0
  63. package/android/common/src/main/java/com/marianhello/bgloc/data/LocationTemplate.java +12 -0
  64. package/android/common/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +65 -0
  65. package/android/common/src/main/java/com/marianhello/bgloc/data/LocationTransform.java +19 -0
  66. package/android/common/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +395 -0
  67. package/android/common/src/main/java/com/marianhello/bgloc/data/provider/LocationContentProvider.java +321 -0
  68. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +76 -0
  69. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +160 -0
  70. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +112 -0
  71. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +506 -0
  72. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +151 -0
  73. package/android/common/src/main/java/com/marianhello/bgloc/headless/AbstractTaskRunner.java +15 -0
  74. package/android/common/src/main/java/com/marianhello/bgloc/headless/ActivityTask.java +48 -0
  75. package/android/common/src/main/java/com/marianhello/bgloc/headless/JsCallback.java +10 -0
  76. package/android/common/src/main/java/com/marianhello/bgloc/headless/LocationTask.java +60 -0
  77. package/android/common/src/main/java/com/marianhello/bgloc/headless/StationaryTask.java +25 -0
  78. package/android/common/src/main/java/com/marianhello/bgloc/headless/Task.java +8 -0
  79. package/android/common/src/main/java/com/marianhello/bgloc/headless/TaskRunner.java +5 -0
  80. package/android/common/src/main/java/com/marianhello/bgloc/headless/TaskRunnerFactory.java +8 -0
  81. package/android/common/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +171 -0
  82. package/android/common/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +282 -0
  83. package/android/common/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +610 -0
  84. package/android/common/src/main/java/com/marianhello/bgloc/provider/LocationProvider.java +32 -0
  85. package/android/common/src/main/java/com/marianhello/bgloc/provider/LocationProviderFactory.java +47 -0
  86. package/android/common/src/main/java/com/marianhello/bgloc/provider/ProviderDelegate.java +12 -0
  87. package/android/common/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +145 -0
  88. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationService.java +16 -0
  89. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +749 -0
  90. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceInfo.java +6 -0
  91. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceInfoImpl.java +41 -0
  92. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java +203 -0
  93. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +130 -0
  94. package/android/common/src/main/java/com/marianhello/bgloc/sync/AccountHelper.java +39 -0
  95. package/android/common/src/main/java/com/marianhello/bgloc/sync/Authenticator.java +68 -0
  96. package/android/common/src/main/java/com/marianhello/bgloc/sync/AuthenticatorService.java +28 -0
  97. package/android/common/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +278 -0
  98. package/android/common/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java +148 -0
  99. package/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +249 -0
  100. package/android/common/src/main/java/com/marianhello/bgloc/sync/SyncService.java +68 -0
  101. package/android/common/src/main/java/com/marianhello/logging/DBLogReader.java +203 -0
  102. package/android/common/src/main/java/com/marianhello/logging/LogEntry.java +99 -0
  103. package/android/common/src/main/java/com/marianhello/logging/LoggerManager.java +70 -0
  104. package/android/common/src/main/java/com/marianhello/logging/UncaughtExceptionLogger.java +36 -0
  105. package/android/common/src/main/java/com/marianhello/utils/CloneHelper.java +22 -0
  106. package/android/common/src/main/java/com/marianhello/utils/Convert.java +56 -0
  107. package/android/common/src/main/java/com/marianhello/utils/TextUtils.java +72 -0
  108. package/android/common/src/main/java/com/marianhello/utils/ToneGenerator.java +68 -0
  109. package/android/common/src/main/java/org/apache/commons/io/Charsets.java +153 -0
  110. package/android/common/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +344 -0
  111. package/android/common/src/main/java/org/chromium/content/browser/ThreadUtils.java +134 -0
  112. package/android/common/src/main/java/ru/andremoniy/sqlbuilder/SqlExpression.java +398 -0
  113. package/android/common/src/main/java/ru/andremoniy/sqlbuilder/SqlSelectStatement.java +671 -0
  114. package/android/common/src/main/java/ru/andremoniy/sqlbuilder/SqlStatement.java +29 -0
  115. package/android/common/src/main/java/ru/andremoniy/utils/TextUtils.java +61 -0
  116. package/android/common/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  117. package/android/common/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  118. package/android/common/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  119. package/android/common/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  120. package/android/common/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  121. package/android/common/src/main/res/values/strings.xml +4 -0
  122. package/android/common/src/main/res/xml/authenticator.xml +7 -0
  123. package/android/common/src/main/res/xml/syncadapter.xml +9 -0
  124. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/ArrayListLocationTemplateTest.java +82 -0
  125. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/BackgroundLocationTest.java +128 -0
  126. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/ConfigTest.java +191 -0
  127. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/DBLogReaderTest.java +37 -0
  128. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/HashMapLocationTemplateTest.java +216 -0
  129. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/HttpPostServiceTest.java +223 -0
  130. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/LocationTemplateFactoryTest.java +50 -0
  131. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/PostLocationTaskTest.java +180 -0
  132. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/TestHelper.java +16 -0
  133. package/android/dependencies.gradle +13 -0
  134. package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.h +41 -0
  135. package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.m +526 -0
  136. package/ios/common/BackgroundGeolocation/CocoaLumberjack.h +1945 -0
  137. package/ios/common/BackgroundGeolocation/CocoaLumberjack.m +5255 -0
  138. package/ios/common/BackgroundGeolocation/FMDB.h +2357 -0
  139. package/ios/common/BackgroundGeolocation/FMDB.m +2672 -0
  140. package/ios/common/BackgroundGeolocation/FMDBLogger.h +42 -0
  141. package/ios/common/BackgroundGeolocation/FMDBLogger.m +264 -0
  142. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.h +41 -0
  143. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.m +68 -0
  144. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager+Internal.h +33 -0
  145. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.h +178 -0
  146. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.m +1025 -0
  147. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.h +103 -0
  148. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.m +238 -0
  149. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequestDefines.h +163 -0
  150. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.h +39 -0
  151. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.m +37 -0
  152. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.h +51 -0
  153. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.m +53 -0
  154. package/ios/common/BackgroundGeolocation/MAURActivity.h +23 -0
  155. package/ios/common/BackgroundGeolocation/MAURActivity.m +52 -0
  156. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.h +18 -0
  157. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +202 -0
  158. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +60 -0
  159. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +638 -0
  160. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +34 -0
  161. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +185 -0
  162. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.h +25 -0
  163. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.m +105 -0
  164. package/ios/common/BackgroundGeolocation/MAURConfig.h +74 -0
  165. package/ios/common/BackgroundGeolocation/MAURConfig.m +485 -0
  166. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +49 -0
  167. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +51 -0
  168. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.h +20 -0
  169. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +514 -0
  170. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.h +17 -0
  171. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +97 -0
  172. package/ios/common/BackgroundGeolocation/MAURLocation.h +59 -0
  173. package/ios/common/BackgroundGeolocation/MAURLocation.m +349 -0
  174. package/ios/common/BackgroundGeolocation/MAURLocationContract.h +34 -0
  175. package/ios/common/BackgroundGeolocation/MAURLocationContract.m +35 -0
  176. package/ios/common/BackgroundGeolocation/MAURLocationManager.h +53 -0
  177. package/ios/common/BackgroundGeolocation/MAURLocationManager.m +287 -0
  178. package/ios/common/BackgroundGeolocation/MAURLogReader.h +26 -0
  179. package/ios/common/BackgroundGeolocation/MAURLogReader.m +122 -0
  180. package/ios/common/BackgroundGeolocation/MAURLogging.h +19 -0
  181. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +40 -0
  182. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +250 -0
  183. package/ios/common/BackgroundGeolocation/MAURProviderDelegate.h +52 -0
  184. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.h +18 -0
  185. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +129 -0
  186. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.h +26 -0
  187. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +278 -0
  188. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.h +57 -0
  189. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.m +93 -0
  190. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +38 -0
  191. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +380 -0
  192. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.h +32 -0
  193. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.m +276 -0
  194. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.h +20 -0
  195. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.m +62 -0
  196. package/ios/common/BackgroundGeolocation/Reachability.h +102 -0
  197. package/ios/common/BackgroundGeolocation/Reachability.m +475 -0
  198. package/ios/common/BackgroundGeolocation/SOMotionDetector/CHANGELOG.md +2 -0
  199. package/ios/common/BackgroundGeolocation/SOMotionDetector/LICENSE +21 -0
  200. package/ios/common/BackgroundGeolocation/SOMotionDetector/README.md +135 -0
  201. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.h +80 -0
  202. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.m +147 -0
  203. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.h +30 -0
  204. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.m +42 -0
  205. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.h +99 -0
  206. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.m +327 -0
  207. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.h +44 -0
  208. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.m +94 -0
  209. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/README.md +170 -0
  210. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.h +55 -0
  211. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.m +47 -0
  212. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlDataManipulationCommand.h +27 -0
  213. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.h +250 -0
  214. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.m +259 -0
  215. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.h +360 -0
  216. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.m +427 -0
  217. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlStatement.h +37 -0
  218. package/ios/common/BackgroundGeolocation.xcodeproj/project.pbxproj +760 -0
  219. package/ios/common/BackgroundGeolocationTests/Info.plist +24 -0
  220. package/ios/common/BackgroundGeolocationTests/MAURBackgroundLocationTest.m +185 -0
  221. package/ios/common/BackgroundGeolocationTests/MAURConfigTest.m +161 -0
  222. package/ios/common/BackgroundGeolocationTests/MAURGeolocationOpenHelperTest.m +102 -0
  223. package/ios/common/BackgroundGeolocationTests/MAURLocationTest.m +216 -0
  224. package/ios/common/BackgroundGeolocationTests/MAURLocationUploaderTest.m +55 -0
  225. package/ios/common/BackgroundGeolocationTests/MAURLogReaderTest.m +43 -0
  226. package/ios/common/BackgroundGeolocationTests/MAURSQLiteConfigurationDAOTest.m +102 -0
  227. package/ios/common/BackgroundGeolocationTests/MAURSQLiteHelperTest.m +41 -0
  228. package/ios/common/BackgroundGeolocationTests/MAURSQLiteLocationDAOTests.m +240 -0
  229. package/ios/common/BackgroundGeolocationTests/MAURSQLiteLocationDAOThreadTest.m +84 -0
  230. package/ios/common/BackgroundGeolocationTests/MAURSQLiteOpenHelperTest.m +144 -0
  231. package/ios/common/CONTRIBUTORS.md +10 -0
  232. package/ios/common/LICENSE +191 -0
  233. package/ios/common/README.md +7 -0
  234. package/ios/common/scripts/xcode-refactor.js +184 -0
  235. package/package.json +44 -0
  236. package/plugin.xml +355 -0
  237. package/www/BackgroundGeolocation.d.ts +910 -0
  238. package/www/BackgroundGeolocation.js +247 -0
  239. package/www/radio.js +177 -0
@@ -0,0 +1,225 @@
1
+ package com.marianhello.bgloc;
2
+
3
+ import android.content.ContentValues;
4
+ import android.content.Context;
5
+ import android.database.Cursor;
6
+ import android.database.sqlite.SQLiteDatabase;
7
+ import android.location.Location;
8
+ import androidx.test.platform.app.InstrumentationRegistry;
9
+ import androidx.test.ext.junit.runners.AndroidJUnit4;
10
+ import androidx.test.filters.SmallTest;
11
+
12
+ import com.marianhello.bgloc.data.BackgroundLocation;
13
+ import com.marianhello.bgloc.data.sqlite.SQLiteConfigurationContract;
14
+ import com.marianhello.bgloc.data.sqlite.SQLiteLocationContract;
15
+ import com.marianhello.bgloc.data.sqlite.SQLiteLocationDAO;
16
+ import com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper;
17
+ import com.marianhello.bgloc.sqlite.SQLiteOpenHelper10;
18
+
19
+ import junit.framework.Assert;
20
+
21
+ import org.json.JSONObject;
22
+ import org.junit.Before;
23
+ import org.junit.Test;
24
+ import org.junit.runner.RunWith;
25
+
26
+ import java.util.ArrayList;
27
+ import java.util.Arrays;
28
+ import java.util.List;
29
+
30
+ /**
31
+ * Created by finch on 13/07/16.
32
+ */
33
+ @RunWith(AndroidJUnit4.class)
34
+ @SmallTest
35
+ public class SQLiteOpenHelperTest {
36
+ @Before
37
+ public void deleteDatabase() {
38
+ Context ctx = InstrumentationRegistry.getTargetContext();
39
+ SQLiteOpenHelper.getHelper(ctx).close();
40
+ ctx.deleteDatabase(SQLiteOpenHelper.SQLITE_DATABASE_NAME);
41
+ }
42
+
43
+ @Test
44
+ public void upgradeDatabaseFromVersion10() {
45
+ Cursor cursor = null;
46
+ Context ctx = InstrumentationRegistry.getTargetContext();
47
+ SQLiteDatabase db10 = new SQLiteOpenHelper10(ctx).getWritableDatabase();
48
+
49
+ Location location = new Location("fake");
50
+ location.setAccuracy(200);
51
+ location.setAltitude(900);
52
+ location.setBearing(2);
53
+ location.setLatitude(40.21);
54
+ location.setLongitude(23.45);
55
+ location.setSpeed(20);
56
+ location.setProvider("test");
57
+ location.setTime(1000);
58
+ BackgroundLocation bgLocation = new BackgroundLocation(location);
59
+
60
+ Config config = Config.getDefault();
61
+ config.setActivitiesInterval(1000);
62
+ config.setDesiredAccuracy(200);
63
+ config.setDistanceFilter(300);
64
+ config.setFastestInterval(5000);
65
+ config.setInterval(10000);
66
+ config.setLocationProvider(0);
67
+ config.setMaxLocations(15000);
68
+ config.setUrl("http://server:1234/locations");
69
+ config.setStopOnTerminate(false);
70
+ config.setStopOnStillActivity(false);
71
+ config.setStationaryRadius(50);
72
+ config.setStartOnBoot(false);
73
+ config.setStartForeground(false);
74
+ config.setSmallNotificationIcon("smallico");
75
+ config.setLargeNotificationIcon("largeico");
76
+ config.setNotificationTitle("test");
77
+ config.setNotificationText("in progress");
78
+ config.setNotificationIconColor("yellow");
79
+
80
+ ContentValues locationValues = new ContentValues();
81
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_TIME, bgLocation.getTime());
82
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_ACCURACY, bgLocation.getAccuracy());
83
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_SPEED, bgLocation.getSpeed());
84
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_BEARING, bgLocation.getBearing());
85
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_ALTITUDE, bgLocation.getAltitude());
86
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LATITUDE, bgLocation.getLatitude());
87
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LONGITUDE, bgLocation.getLongitude());
88
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_PROVIDER, bgLocation.getProvider());
89
+ locationValues.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LOCATION_PROVIDER, bgLocation.getLocationProvider());
90
+
91
+ db10.insert(SQLiteLocationContract.LocationEntry.TABLE_NAME, null, locationValues);
92
+ cursor = db10.query(SQLiteLocationContract.LocationEntry.TABLE_NAME, null, null, null, null, null, null);
93
+ Assert.assertEquals(1, cursor.getCount());
94
+ cursor.close();
95
+
96
+ ContentValues configValues = new ContentValues();
97
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_RADIUS, config.getStationaryRadius());
98
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER, config.getDistanceFilter());
99
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY, config.getDesiredAccuracy());
100
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_DEBUG, (config.isDebugging() == true) ? 1 : 0);
101
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE, config.getNotificationTitle());
102
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT, config.getNotificationText());
103
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL, config.getSmallNotificationIcon());
104
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE, config.getLargeNotificationIcon());
105
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR, config.getNotificationIconColor());
106
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE, (config.getStopOnTerminate() == true) ? 1 : 0);
107
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_START_BOOT, (config.getStartOnBoot() == true) ? 1 : 0);
108
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_START_FOREGROUND, (config.getStartForeground() == true) ? 1 : 0);
109
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER, config.getLocationProvider());
110
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_INTERVAL, config.getInterval());
111
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL, config.getFastestInterval());
112
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL, config.getActivitiesInterval());
113
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_URL, config.getUrl());
114
+ configValues.put(SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_HEADERS, new JSONObject(config.getHttpHeaders()).toString());
115
+
116
+ db10.insert(SQLiteConfigurationContract.ConfigurationEntry.TABLE_NAME, null, configValues);
117
+ cursor = db10.query(SQLiteConfigurationContract.ConfigurationEntry.TABLE_NAME, null, null, null, null, null, null);
118
+ Assert.assertEquals(1, cursor.getCount());
119
+ cursor.close();
120
+
121
+ db10.close();
122
+
123
+ // begin test
124
+
125
+ List<String> columnNames = null;
126
+ SQLiteDatabase db = new SQLiteOpenHelper(ctx).getWritableDatabase();
127
+
128
+ cursor = db.query(SQLiteLocationContract.LocationEntry.TABLE_NAME, null, null, null, null, null, null);
129
+ columnNames = Arrays.asList(cursor.getColumnNames());
130
+
131
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_TIME)));
132
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_ACCURACY)));
133
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_SPEED)));
134
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_BEARING)));
135
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_ALTITUDE)));
136
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_LATITUDE)));
137
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_LONGITUDE)));
138
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_RADIUS)));
139
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_HAS_ACCURACY)));
140
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_HAS_SPEED)));
141
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_HAS_BEARING)));
142
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_HAS_ALTITUDE)));
143
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_HAS_RADIUS)));
144
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_PROVIDER)));
145
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_LOCATION_PROVIDER)));
146
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_STATUS)));
147
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_BATCH_START_MILLIS)));
148
+ Assert.assertTrue(columnNames.contains((SQLiteLocationContract.LocationEntry.COLUMN_NAME_MOCK_FLAGS)));
149
+
150
+ cursor.close();
151
+
152
+ // locations should survive db upgrade
153
+ SQLiteLocationDAO dao = new SQLiteLocationDAO(db);
154
+ ArrayList<BackgroundLocation> locations = new ArrayList(dao.getAllLocations());
155
+ Assert.assertEquals(1, locations.size());
156
+
157
+ BackgroundLocation storedLocation = locations.get(0);
158
+ Assert.assertEquals(200, storedLocation.getAccuracy(), 0);
159
+ Assert.assertEquals(900, storedLocation.getAltitude(), 0);
160
+ Assert.assertEquals(2, storedLocation.getBearing(), 0);
161
+ Assert.assertEquals(40.21, storedLocation.getLatitude(), 0);
162
+ Assert.assertEquals(23.45, storedLocation.getLongitude(), 0);
163
+ Assert.assertEquals(20, storedLocation.getSpeed(), 0);
164
+ Assert.assertEquals("test", storedLocation.getProvider(), "test");
165
+ Assert.assertEquals(1000, storedLocation.getTime(), 0);
166
+
167
+
168
+ // test configuration table upgrade
169
+
170
+ cursor = db.query(SQLiteConfigurationContract.ConfigurationEntry.TABLE_NAME, null, null, null, null, null, null);
171
+ columnNames = Arrays.asList(cursor.getColumnNames());
172
+
173
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_RADIUS)));
174
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER)));
175
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY)));
176
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_DEBUG)));
177
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE)));
178
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT)));
179
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE)));
180
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL)));
181
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR)));
182
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_START_BOOT)));
183
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_START_FOREGROUND)));
184
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_STOP_ON_STILL)));
185
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE)));
186
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER)));
187
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_INTERVAL)));
188
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL)));
189
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL)));
190
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_URL)));
191
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_SYNC_URL)));
192
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD)));
193
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_HEADERS)));
194
+ Assert.assertTrue(columnNames.contains((SQLiteConfigurationContract.ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS)));
195
+
196
+ cursor.close();
197
+
198
+ // SQLiteConfigurationDAO configDAO = new SQLiteConfigurationDAO(db);
199
+ // try {
200
+ // Config storedConfig = configDAO.retrieveConfiguration();
201
+ // Assert.assertEquals(1000, storedConfig.getActivitiesInterval().intValue());
202
+ // Assert.assertEquals(200, storedConfig.getDesiredAccuracy().intValue());
203
+ // Assert.assertEquals(300, storedConfig.getDistanceFilter().intValue());
204
+ // Assert.assertEquals(5000, storedConfig.getFastestInterval().intValue());
205
+ // Assert.assertEquals(10000, storedConfig.getInterval().intValue());
206
+ // Assert.assertEquals(0, storedConfig.getLocationProvider().intValue());
207
+ // Assert.assertEquals(10000, storedConfig.getMaxLocations().intValue());
208
+ // Assert.assertEquals("http://server:1234/locations", storedConfig.getUrl());
209
+ // Assert.assertEquals(Boolean.FALSE, storedConfig.getStopOnTerminate());
210
+ // Assert.assertEquals(Boolean.FALSE, storedConfig.getStopOnStillActivity());
211
+ // Assert.assertEquals(50, storedConfig.getStationaryRadius(), 0);
212
+ // Assert.assertEquals(Boolean.FALSE, storedConfig.getStartOnBoot());
213
+ // Assert.assertEquals(Boolean.FALSE, storedConfig.getStartForeground());
214
+ // Assert.assertEquals("smallico", storedConfig.getSmallNotificationIcon());
215
+ // Assert.assertEquals("largeico", storedConfig.getLargeNotificationIcon());
216
+ // Assert.assertEquals("test", storedConfig.getNotificationTitle());
217
+ // Assert.assertEquals("in progress", storedConfig.getNotificationText());
218
+ // Assert.assertEquals("yellow", storedConfig.getNotificationIconColor());
219
+ //// Assert.assertEquals("", storedConfig.getHttpHeaders());
220
+ //
221
+ // } catch (JSONException e) {
222
+ // Assert.fail(e.getMessage());
223
+ // }
224
+ }
225
+ }
@@ -0,0 +1,46 @@
1
+ package com.marianhello.bgloc;
2
+
3
+ import com.marianhello.bgloc.data.BackgroundActivity;
4
+ import com.marianhello.bgloc.data.BackgroundLocation;
5
+
6
+ public class TestPluginDelegate implements PluginDelegate {
7
+ @Override
8
+ public void onAuthorizationChanged(int authStatus) {
9
+
10
+ }
11
+
12
+ @Override
13
+ public void onLocationChanged(BackgroundLocation location) {
14
+
15
+ }
16
+
17
+ @Override
18
+ public void onStationaryChanged(BackgroundLocation location) {
19
+
20
+ }
21
+
22
+ @Override
23
+ public void onActivityChanged(BackgroundActivity activity) {
24
+
25
+ }
26
+
27
+ @Override
28
+ public void onServiceStatusChanged(int status) {
29
+
30
+ }
31
+
32
+ @Override
33
+ public void onAbortRequested() {
34
+
35
+ }
36
+
37
+ @Override
38
+ public void onHttpAuthorization() {
39
+
40
+ }
41
+
42
+ @Override
43
+ public void onError(PluginException error) {
44
+
45
+ }
46
+ }
@@ -0,0 +1,14 @@
1
+ package com.marianhello.bgloc;
2
+
3
+ import com.marianhello.bgloc.test.TestConstants;
4
+
5
+ public class TestResourceResolver extends ResourceResolver {
6
+
7
+ public TestResourceResolver() {
8
+
9
+ }
10
+
11
+ public String getAuthority() {
12
+ return TestConstants.Authority;
13
+ }
14
+ }
@@ -0,0 +1,50 @@
1
+ package com.marianhello.bgloc.provider;
2
+
3
+ import android.location.Location;
4
+
5
+ import java.util.ArrayList;
6
+ import java.util.Iterator;
7
+ import java.util.List;
8
+
9
+ public class MockLocationProvider extends AbstractLocationProvider {
10
+ private boolean mIsStarted = false;
11
+ private List<Location> mMockLocations = new ArrayList();
12
+
13
+ public MockLocationProvider() {
14
+ super(null);
15
+ PROVIDER_ID = 99;
16
+ }
17
+
18
+ @Override
19
+ public void onStart() {
20
+ mIsStarted = true;
21
+ Iterator<Location> it = mMockLocations.iterator();
22
+ while(mIsStarted && it.hasNext()) {
23
+ handleLocation(it.next());
24
+ try {
25
+ Thread.sleep(1000);
26
+ } catch (InterruptedException e) {
27
+ mIsStarted = false;
28
+ }
29
+ }
30
+ }
31
+
32
+ @Override
33
+ public void onStop() {
34
+ mIsStarted = false;
35
+ }
36
+
37
+ @Override
38
+ public boolean isStarted() {
39
+ return false;
40
+ }
41
+
42
+ @Override
43
+ public Boolean hasMockLocationsEnabled() {
44
+ return true;
45
+ }
46
+
47
+ public void setMockLocations(List<Location> locations) {
48
+ mMockLocations = locations;
49
+ }
50
+ }
@@ -0,0 +1,17 @@
1
+ package com.marianhello.bgloc.provider;
2
+
3
+ public class TestLocationProviderFactory extends LocationProviderFactory {
4
+ private LocationProvider mProvider = new MockLocationProvider();
5
+
6
+ public TestLocationProviderFactory() {
7
+ super(null);
8
+ }
9
+
10
+ public LocationProvider getInstance (Integer locationProvider) {
11
+ return mProvider;
12
+ }
13
+
14
+ public void setProvider(LocationProvider provider) {
15
+ mProvider = mProvider;
16
+ }
17
+ }
@@ -0,0 +1,92 @@
1
+ package com.marianhello.bgloc.sqlite;
2
+
3
+ import android.content.Context;
4
+ import android.database.sqlite.SQLiteDatabase;
5
+ import android.util.Log;
6
+
7
+ import com.marianhello.bgloc.data.sqlite.SQLiteLocationContract.LocationEntry;
8
+ import com.marianhello.bgloc.data.sqlite.SQLiteConfigurationContract.ConfigurationEntry;
9
+
10
+ /**
11
+ * Created by finch on 13/07/16.
12
+ */
13
+ public class SQLiteOpenHelper10 extends android.database.sqlite.SQLiteOpenHelper {
14
+ private static final String SQLITE_DATABASE_NAME = "cordova_bg_geolocation.db";
15
+ private static final int DATABASE_VERSION = 10;
16
+ private static final String TEXT_TYPE = " TEXT";
17
+ private static final String INTEGER_TYPE = " INTEGER";
18
+ private static final String REAL_TYPE = " REAL";
19
+ private static final String COMMA_SEP = ",";
20
+
21
+ private static final String SQL_CREATE_LOCATION_TABLE =
22
+ "CREATE TABLE " + LocationEntry.TABLE_NAME + " (" +
23
+ LocationEntry._ID + " INTEGER PRIMARY KEY," +
24
+ LocationEntry.COLUMN_NAME_TIME + INTEGER_TYPE + COMMA_SEP +
25
+ LocationEntry.COLUMN_NAME_ACCURACY + REAL_TYPE + COMMA_SEP +
26
+ LocationEntry.COLUMN_NAME_SPEED + REAL_TYPE + COMMA_SEP +
27
+ LocationEntry.COLUMN_NAME_BEARING + REAL_TYPE + COMMA_SEP +
28
+ LocationEntry.COLUMN_NAME_ALTITUDE + REAL_TYPE + COMMA_SEP +
29
+ LocationEntry.COLUMN_NAME_LATITUDE + REAL_TYPE + COMMA_SEP +
30
+ LocationEntry.COLUMN_NAME_LONGITUDE + REAL_TYPE + COMMA_SEP +
31
+ LocationEntry.COLUMN_NAME_PROVIDER + TEXT_TYPE + COMMA_SEP +
32
+ LocationEntry.COLUMN_NAME_LOCATION_PROVIDER + INTEGER_TYPE + COMMA_SEP +
33
+ "debug" + INTEGER_TYPE +
34
+ " )";
35
+
36
+ private static final String SQL_CREATE_CONFIG_TABLE =
37
+ "CREATE TABLE " + ConfigurationEntry.TABLE_NAME + " (" +
38
+ ConfigurationEntry._ID + " INTEGER PRIMARY KEY," +
39
+ ConfigurationEntry.COLUMN_NAME_RADIUS + REAL_TYPE + COMMA_SEP +
40
+ ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER + INTEGER_TYPE + COMMA_SEP +
41
+ ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY + INTEGER_TYPE + COMMA_SEP +
42
+ ConfigurationEntry.COLUMN_NAME_DEBUG + INTEGER_TYPE + COMMA_SEP +
43
+ ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE + TEXT_TYPE + COMMA_SEP +
44
+ ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT + TEXT_TYPE + COMMA_SEP +
45
+ ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL + TEXT_TYPE + COMMA_SEP +
46
+ ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE + TEXT_TYPE + COMMA_SEP +
47
+ ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR + TEXT_TYPE + COMMA_SEP +
48
+ ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE + INTEGER_TYPE + COMMA_SEP +
49
+ ConfigurationEntry.COLUMN_NAME_START_BOOT + INTEGER_TYPE + COMMA_SEP +
50
+ ConfigurationEntry.COLUMN_NAME_START_FOREGROUND + INTEGER_TYPE + COMMA_SEP +
51
+ ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER + TEXT_TYPE + COMMA_SEP +
52
+ ConfigurationEntry.COLUMN_NAME_INTERVAL + INTEGER_TYPE + COMMA_SEP +
53
+ ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL + INTEGER_TYPE + COMMA_SEP +
54
+ ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL + INTEGER_TYPE + COMMA_SEP +
55
+ ConfigurationEntry.COLUMN_NAME_URL + TEXT_TYPE + COMMA_SEP +
56
+ ConfigurationEntry.COLUMN_NAME_HEADERS + TEXT_TYPE +
57
+ " )";
58
+
59
+ private static final String SQL_DELETE_CONFIG_TABLE =
60
+ "DROP TABLE IF EXISTS " + ConfigurationEntry.TABLE_NAME;
61
+
62
+ private static final String SQL_DELETE_LOCATION_TABLE =
63
+ "DROP TABLE IF EXISTS " + LocationEntry.TABLE_NAME;
64
+
65
+ public SQLiteOpenHelper10(Context context) {
66
+ super(context, SQLITE_DATABASE_NAME, null, DATABASE_VERSION);
67
+ }
68
+
69
+ @Override
70
+ public void onCreate(SQLiteDatabase db) {
71
+ db.execSQL(SQL_CREATE_LOCATION_TABLE);
72
+ Log.d(this.getClass().getName(), SQL_CREATE_LOCATION_TABLE);
73
+ db.execSQL(SQL_CREATE_CONFIG_TABLE);
74
+ Log.d(this.getClass().getName(), SQL_CREATE_CONFIG_TABLE);
75
+ }
76
+
77
+ @Override
78
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
79
+ // This database is only a cache for online data, so its upgrade policy is
80
+ // to simply to discard the data and start over
81
+ db.execSQL(SQL_DELETE_LOCATION_TABLE);
82
+ Log.d(this.getClass().getName(), SQL_DELETE_LOCATION_TABLE);
83
+ db.execSQL(SQL_DELETE_CONFIG_TABLE);
84
+ Log.d(this.getClass().getName(), SQL_DELETE_CONFIG_TABLE);
85
+ onCreate(db);
86
+ }
87
+
88
+ @Override
89
+ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
90
+ onUpgrade(db, oldVersion, newVersion);
91
+ }
92
+ }
@@ -0,0 +1,107 @@
1
+ package com.marianhello.bgloc.test;
2
+
3
+ import android.content.Context;
4
+ import android.content.SharedPreferences;
5
+ import android.content.pm.ProviderInfo;
6
+ import android.content.res.Resources;
7
+ import android.test.AndroidTestCase;
8
+ import android.test.IsolatedContext;
9
+ import android.test.RenamingDelegatingContext;
10
+ import android.test.mock.MockContentResolver;
11
+ import android.test.mock.MockContext;
12
+
13
+ import com.marianhello.bgloc.data.provider.LocationContentProvider;
14
+ import com.marianhello.bgloc.test.TestConstants;
15
+
16
+ /**
17
+ * @author diego
18
+ * https://stackoverflow.com/a/5281044
19
+ *
20
+ */
21
+ public class LocationProviderTestCase extends AndroidTestCase {
22
+ Class<LocationContentProvider> mProviderClass;
23
+ String mProviderAuthority;
24
+
25
+ private IsolatedContext mProviderContext;
26
+ private LocationContentProvider mProvider;
27
+ private MockContentResolver mResolver;
28
+
29
+ /**
30
+ * The renaming prefix.
31
+ */
32
+ private static final String filenamePrefix = "test.";
33
+
34
+ public LocationProviderTestCase() {
35
+ mProviderClass = LocationContentProvider.class;
36
+ mProviderAuthority = TestConstants.Authority;
37
+ }
38
+
39
+ @Override
40
+ protected void setUp() throws Exception {
41
+ super.setUp();
42
+
43
+ mResolver = new MockContentResolver();
44
+ RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(
45
+ new DelegatedMockContext(getContext()), // The context that most methods are delegated to
46
+ getContext(), // The context that file methods are delegated to
47
+ filenamePrefix);
48
+ mProviderContext = new IsolatedContext(mResolver, targetContextWrapper);
49
+
50
+ ProviderInfo providerInfo = new ProviderInfo();
51
+ providerInfo.authority = mProviderAuthority;
52
+
53
+ mProvider = mProviderClass.newInstance();
54
+ mProvider.attachInfo(mProviderContext, providerInfo);
55
+ assertNotNull(mProvider);
56
+ mResolver.addProvider(mProviderAuthority, mProvider);
57
+ }
58
+
59
+ public LocationContentProvider getProvider() {
60
+ return mProvider;
61
+ }
62
+
63
+ public MockContentResolver getMockContentResolver() {
64
+ return mResolver;
65
+ }
66
+
67
+ public IsolatedContext getMockContext() {
68
+ return mProviderContext;
69
+ }
70
+
71
+ public void testProviderSampleCreation() {
72
+ LocationContentProvider provider = getProvider();
73
+ assertNotNull(provider);
74
+ }
75
+
76
+ /**
77
+ * The DelegatedMockContext.
78
+ *
79
+ */
80
+ private static class DelegatedMockContext extends MockContext {
81
+
82
+ private Context mDelegatedContext;
83
+
84
+ public DelegatedMockContext(Context context) {
85
+ mDelegatedContext = context;
86
+ }
87
+
88
+ @Override
89
+ public SharedPreferences getSharedPreferences(String name, int mode) {
90
+ return mDelegatedContext.getSharedPreferences(filenamePrefix + name, mode);
91
+ }
92
+
93
+ @Override
94
+ public Context getApplicationContext() {
95
+ return mDelegatedContext.getApplicationContext();
96
+ }
97
+
98
+ @Override
99
+ public Resources getResources() {
100
+ return mDelegatedContext.getResources();
101
+ }
102
+
103
+ @Override
104
+ public String getPackageName() {
105
+ return mDelegatedContext.getPackageName();
106
+ }
107
+ }}
@@ -0,0 +1,5 @@
1
+ package com.marianhello.bgloc.test;
2
+
3
+ abstract public class TestConstants {
4
+ public static final String Authority = "com.marianhello.app.plugin.bgloc.provider";
5
+ }
@@ -0,0 +1,72 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!--
3
+ Licensed to the Apache Software Foundation (ASF) under one
4
+ or more contributor license agreements. See the NOTICE file
5
+ distributed with this work for additional information
6
+ regarding copyright ownership. The ASF licenses this file
7
+ to you under the Apache License, Version 2.0 (the
8
+ "License"); you may not use this file except in compliance
9
+ with the License. You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing,
14
+ software distributed under the License is distributed on an
15
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ KIND, either express or implied. See the License for the
17
+ specific language governing permissions and limitations
18
+ under the License.
19
+ -->
20
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
21
+ package="com.marianhello.backgroundgeolocation" android:versionName="1.0" android:versionCode="1">
22
+ <application>
23
+ <service
24
+ android:name="com.marianhello.bgloc.sync.SyncService"
25
+ android:exported="true"
26
+ android:process=":sync">
27
+ <intent-filter>
28
+ <action android:name="android.content.SyncAdapter"/>
29
+ </intent-filter>
30
+ <meta-data android:name="android.content.SyncAdapter"
31
+ android:resource="@xml/syncadapter"/>
32
+ </service>
33
+ <service
34
+ android:exported="false"
35
+ android:name="com.marianhello.bgloc.sync.AuthenticatorService">
36
+ <intent-filter>
37
+ <action android:name="android.accounts.AccountAuthenticator"/>
38
+ </intent-filter>
39
+ <meta-data
40
+ android:name="android.accounts.AccountAuthenticator"
41
+ android:resource="@xml/authenticator" />
42
+ </service>
43
+ <provider
44
+ android:name="com.marianhello.bgloc.data.provider.LocationContentProvider"
45
+ android:authorities="@string/plugin_bgloc_content_authority"
46
+ android:exported="false"
47
+ android:syncable="true"/>
48
+ <service android:enabled="true" android:exported="false" android:name="com.marianhello.bgloc.service.LocationServiceImpl" />
49
+ <receiver android:enabled="true" android:exported="true" android:name="com.marianhello.bgloc.BootCompletedReceiver">
50
+ <intent-filter>
51
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
52
+ </intent-filter>
53
+ </receiver>
54
+ <uses-library android:name="org.apache.http.legacy" android:required="true" />
55
+ </application>
56
+
57
+ <uses-permission android:name="android.hardware.location" />
58
+ <uses-permission android:name="android.permission.INTERNET"/>
59
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
60
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
61
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
62
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
63
+ <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
64
+ <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
65
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
66
+ <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
67
+ <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
68
+ <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
69
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
70
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
71
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
72
+ </manifest>