@josuelmm/cordova-background-geolocation 4.2.3 → 4.5.2

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 (103) hide show
  1. package/.npmignore +11 -0
  2. package/CHANGELOG.md +261 -0
  3. package/README.md +306 -115
  4. package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/ConfigMapper.java +34 -0
  5. package/android/CDVBackgroundGeolocation/src/main/java/com/tenforwardconsulting/bgloc/cordova/BackgroundGeolocationPlugin.java +61 -1
  6. package/android/common/src/main/AndroidManifest.xml +1 -1
  7. package/android/common/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +20 -3
  8. package/android/common/src/main/java/com/marianhello/bgloc/Config.java +87 -1
  9. package/android/common/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +94 -0
  10. package/android/common/src/main/java/com/marianhello/bgloc/data/ConfigJsonMapper.java +211 -0
  11. package/android/common/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +6 -0
  12. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +5 -1
  13. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +32 -1
  14. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +12 -2
  15. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +33 -2
  16. package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +15 -1
  17. package/android/common/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +48 -1
  18. package/android/common/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +105 -6
  19. package/android/common/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +336 -250
  20. package/android/common/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +69 -19
  21. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +246 -21
  22. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +5 -2
  23. package/android/common/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +46 -13
  24. package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.m +23 -1
  25. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +208 -70
  26. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +132 -5
  27. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +20 -0
  28. package/ios/common/BackgroundGeolocation/MAURConfig.h +7 -0
  29. package/ios/common/BackgroundGeolocation/MAURConfig.m +37 -2
  30. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +3 -0
  31. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +3 -1
  32. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +10 -1
  33. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +15 -1
  34. package/ios/common/BackgroundGeolocation/MAURLocation.h +12 -0
  35. package/ios/common/BackgroundGeolocation/MAURLocation.m +33 -4
  36. package/ios/common/BackgroundGeolocation/MAURLocationContract.h +4 -0
  37. package/ios/common/BackgroundGeolocation/MAURLocationContract.m +5 -1
  38. package/ios/common/BackgroundGeolocation/MAURLocationManager.m +19 -1
  39. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +9 -0
  40. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +59 -1
  41. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +10 -1
  42. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +54 -4
  43. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +12 -0
  44. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +125 -5
  45. package/package.json +31 -1
  46. package/plugin.xml +3 -10
  47. package/www/BackgroundGeolocation.d.ts +143 -3
  48. package/www/BackgroundGeolocation.js +11 -4
  49. package/CLAUDE.md +0 -56
  50. package/HISTORY.md +0 -871
  51. package/android/CDVBackgroundGeolocation/src/test/java/com/marianhello/ConfigMapperTest.java +0 -220
  52. package/android/common/src/androidTest/java/com/marianhello/bgloc/BackgroundGeolocationFacadeTest.java +0 -45
  53. package/android/common/src/androidTest/java/com/marianhello/bgloc/BatchManagerTest.java +0 -570
  54. package/android/common/src/androidTest/java/com/marianhello/bgloc/ConfigTest.java +0 -76
  55. package/android/common/src/androidTest/java/com/marianhello/bgloc/ContentProviderLocationDAOTest.java +0 -437
  56. package/android/common/src/androidTest/java/com/marianhello/bgloc/DBLogReaderTest.java +0 -95
  57. package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationContentProviderTest.java +0 -159
  58. package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationServiceProxyTest.java +0 -161
  59. package/android/common/src/androidTest/java/com/marianhello/bgloc/LocationServiceTest.java +0 -247
  60. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteConfigurationDAOTest.java +0 -200
  61. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteLocationDAOTest.java +0 -457
  62. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteLocationDAOThreadTest.java +0 -96
  63. package/android/common/src/androidTest/java/com/marianhello/bgloc/SQLiteOpenHelperTest.java +0 -225
  64. package/android/common/src/androidTest/java/com/marianhello/bgloc/TestPluginDelegate.java +0 -46
  65. package/android/common/src/androidTest/java/com/marianhello/bgloc/TestResourceResolver.java +0 -14
  66. package/android/common/src/androidTest/java/com/marianhello/bgloc/provider/MockLocationProvider.java +0 -50
  67. package/android/common/src/androidTest/java/com/marianhello/bgloc/provider/TestLocationProviderFactory.java +0 -17
  68. package/android/common/src/androidTest/java/com/marianhello/bgloc/sqlite/SQLiteOpenHelper10.java +0 -92
  69. package/android/common/src/androidTest/java/com/marianhello/bgloc/test/LocationProviderTestCase.java +0 -107
  70. package/android/common/src/androidTest/java/com/marianhello/bgloc/test/TestConstants.java +0 -5
  71. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/ArrayListLocationTemplateTest.java +0 -82
  72. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/BackgroundLocationTest.java +0 -128
  73. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/ConfigTest.java +0 -191
  74. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/DBLogReaderTest.java +0 -37
  75. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/HashMapLocationTemplateTest.java +0 -216
  76. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/HttpPostServiceTest.java +0 -223
  77. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/LocationTemplateFactoryTest.java +0 -50
  78. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/PostLocationTaskTest.java +0 -180
  79. package/android/common/src/test/java/com/marianhello/backgroundgeolocation/TestHelper.java +0 -16
  80. package/ios/common/BackgroundGeolocation/SOMotionDetector/CHANGELOG.md +0 -2
  81. package/ios/common/BackgroundGeolocation/SOMotionDetector/LICENSE +0 -21
  82. package/ios/common/BackgroundGeolocation/SOMotionDetector/README.md +0 -135
  83. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.h +0 -80
  84. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.m +0 -147
  85. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.h +0 -30
  86. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.m +0 -42
  87. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.h +0 -99
  88. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.m +0 -327
  89. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.h +0 -44
  90. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.m +0 -94
  91. package/ios/common/BackgroundGeolocationTests/Info.plist +0 -24
  92. package/ios/common/BackgroundGeolocationTests/MAURBackgroundLocationTest.m +0 -185
  93. package/ios/common/BackgroundGeolocationTests/MAURConfigTest.m +0 -161
  94. package/ios/common/BackgroundGeolocationTests/MAURGeolocationOpenHelperTest.m +0 -102
  95. package/ios/common/BackgroundGeolocationTests/MAURLocationTest.m +0 -216
  96. package/ios/common/BackgroundGeolocationTests/MAURLocationUploaderTest.m +0 -55
  97. package/ios/common/BackgroundGeolocationTests/MAURLogReaderTest.m +0 -43
  98. package/ios/common/BackgroundGeolocationTests/MAURSQLiteConfigurationDAOTest.m +0 -102
  99. package/ios/common/BackgroundGeolocationTests/MAURSQLiteHelperTest.m +0 -41
  100. package/ios/common/BackgroundGeolocationTests/MAURSQLiteLocationDAOTests.m +0 -240
  101. package/ios/common/BackgroundGeolocationTests/MAURSQLiteLocationDAOThreadTest.m +0 -84
  102. package/ios/common/BackgroundGeolocationTests/MAURSQLiteOpenHelperTest.m +0 -144
  103. package/ios/common/scripts/xcode-refactor.js +0 -184
@@ -1,220 +0,0 @@
1
- package com.marianhello;
2
-
3
- import com.marianhello.bgloc.Config;
4
- import com.marianhello.bgloc.cordova.ConfigMapper;
5
- import com.marianhello.bgloc.data.ArrayListLocationTemplate;
6
- import com.marianhello.bgloc.data.HashMapLocationTemplate;
7
- import com.marianhello.bgloc.data.LocationTemplate;
8
- import com.marianhello.bgloc.data.LocationTemplateFactory;
9
-
10
- import junit.framework.Assert;
11
-
12
- import org.json.JSONException;
13
- import org.json.JSONObject;
14
- import org.junit.Test;
15
- import org.junit.runner.RunWith;
16
- import org.robolectric.RobolectricTestRunner;
17
-
18
- import java.util.ArrayList;
19
- import java.util.HashMap;
20
-
21
- /**
22
- * Created by finch on 15.12.2017.
23
- */
24
-
25
- @RunWith(RobolectricTestRunner.class)
26
- public class ConfigMapperTest {
27
- @Test
28
- public void testDefaultToJSONObject() throws JSONException {
29
- Config config = Config.getDefault();
30
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
31
- Assert.assertEquals(config.getStationaryRadius(), jConfig.getDouble("stationaryRadius"), 0f);
32
- Assert.assertEquals(config.getDistanceFilter().intValue(), jConfig.getInt("distanceFilter"));
33
- Assert.assertEquals(config.getDesiredAccuracy().intValue(), jConfig.getInt("desiredAccuracy"));
34
- Assert.assertEquals(config.isDebugging().booleanValue(), jConfig.getBoolean("debug"));
35
- Assert.assertEquals(config.getNotificationTitle(), jConfig.getString("notificationTitle"));
36
- Assert.assertEquals(config.getNotificationText(), jConfig.getString("notificationText"));
37
- Assert.assertEquals(config.getNotificationSyncTitle(), jConfig.getString("notificationSyncTitle"));
38
- Assert.assertEquals(config.getNotificationSyncText(), jConfig.getString("notificationSyncText"));
39
- Assert.assertEquals(config.getNotificationSyncCompletedText(), jConfig.getString("notificationSyncCompletedText"));
40
- Assert.assertEquals(config.getNotificationSyncFailedText(), jConfig.getString("notificationSyncFailedText"));
41
- Assert.assertEquals(config.getStopOnTerminate().booleanValue(), jConfig.getBoolean("stopOnTerminate"));
42
- Assert.assertEquals(config.getStartOnBoot().booleanValue(), jConfig.getBoolean("startOnBoot"));
43
- Assert.assertEquals(config.getLocationProvider().intValue(), jConfig.getInt("locationProvider"));
44
- Assert.assertEquals(config.getInterval().intValue(), jConfig.getInt("interval"));
45
- Assert.assertEquals(config.getFastestInterval().intValue(), jConfig.getInt("fastestInterval"));
46
- Assert.assertEquals(config.getActivitiesInterval().intValue(), jConfig.getInt("activitiesInterval"));
47
- Assert.assertEquals(config.getNotificationIconColor(), jConfig.getString("notificationIconColor"));
48
- Assert.assertEquals(config.getLargeNotificationIcon(), jConfig.getString("notificationIconLarge"));
49
- Assert.assertEquals(config.getSmallNotificationIcon(), jConfig.getString("notificationIconSmall"));
50
- Assert.assertEquals(config.getStartForeground().booleanValue(), jConfig.getBoolean("startForeground"));
51
- Assert.assertEquals(config.getStopOnStillActivity().booleanValue(), jConfig.getBoolean("stopOnStillActivity"));
52
- Assert.assertEquals(config.getUrl(), jConfig.getString("url"));
53
- Assert.assertEquals(config.getSyncUrl(), jConfig.getString("syncUrl"));
54
- Assert.assertEquals(config.getSyncThreshold().intValue(), jConfig.getInt("syncThreshold"));
55
- Assert.assertEquals(Boolean.TRUE.equals(config.getSyncEnabled()), jConfig.getBoolean("sync"));
56
- Assert.assertEquals(new JSONObject(config.getHttpHeaders()).toString(), jConfig.getJSONObject("httpHeaders").toString());
57
- Assert.assertEquals(config.getMaxLocations().intValue(), jConfig.getInt("maxLocations"));
58
- Assert.assertEquals(LocationTemplateFactory.getDefault().toString(), jConfig.get("postTemplate").toString());
59
- }
60
-
61
- @Test
62
- public void testNullableProps() throws JSONException {
63
- JSONObject json = new JSONObject();
64
- json.put("url", JSONObject.NULL);
65
- json.put("syncUrl", JSONObject.NULL);
66
- json.put("notificationIconColor", JSONObject.NULL);
67
- json.put("notificationTitle", JSONObject.NULL);
68
- json.put("notificationText", JSONObject.NULL);
69
- json.put("notificationIconLarge", JSONObject.NULL);
70
- json.put("notificationIconSmall", JSONObject.NULL);
71
-
72
- Config config = ConfigMapper.fromJSONObject(json);
73
-
74
- Assert.assertEquals(Config.NullString, config.getUrl());
75
- Assert.assertTrue(config.hasUrl());
76
- Assert.assertFalse(config.hasValidUrl());
77
-
78
- Assert.assertEquals(Config.NullString, config.getSyncUrl());
79
- Assert.assertTrue(config.hasSyncUrl());
80
- Assert.assertFalse(config.hasValidSyncUrl());
81
-
82
- Assert.assertEquals(Config.NullString, config.getNotificationIconColor());
83
- Assert.assertFalse(config.hasNotificationIconColor());
84
-
85
- Assert.assertEquals(Config.NullString, config.getNotificationTitle());
86
- Assert.assertTrue(config.hasNotificationTitle());
87
-
88
- Assert.assertEquals(Config.NullString, config.getNotificationText());
89
- Assert.assertTrue(config.hasNotificationText());
90
-
91
- Assert.assertEquals(Config.NullString, config.getLargeNotificationIcon());
92
- Assert.assertFalse(config.hasLargeNotificationIcon());
93
-
94
- Assert.assertEquals(Config.NullString, config.getSmallNotificationIcon());
95
- Assert.assertFalse(config.hasSmallNotificationIcon());
96
- }
97
-
98
- /** When "sync" is not in JSON, getSyncEnabled() must return true (default). */
99
- @Test
100
- public void testSyncDefaultWhenNotInJson() throws JSONException {
101
- Config config = ConfigMapper.fromJSONObject(new JSONObject());
102
- Assert.assertTrue("sync not in JSON should default to true", config.getSyncEnabled());
103
- }
104
-
105
- @Test
106
- public void testNullablePropsToJSONObject() throws JSONException {
107
- Config config = new Config();
108
- config.setUrl(Config.NullString);
109
- config.setSyncUrl(Config.NullString);
110
- config.setNotificationIconColor(Config.NullString);
111
- config.setNotificationTitle(Config.NullString);
112
- config.setNotificationText(Config.NullString);
113
- config.setLargeNotificationIcon(Config.NullString);
114
- config.setSmallNotificationIcon(Config.NullString);
115
-
116
- JSONObject json = ConfigMapper.toJSONObject(config);
117
-
118
- Assert.assertEquals(JSONObject.NULL, json.get("url"));
119
- Assert.assertEquals(JSONObject.NULL, json.get("syncUrl"));
120
- Assert.assertEquals(JSONObject.NULL, json.get("notificationIconColor"));
121
- Assert.assertEquals(JSONObject.NULL, json.get("notificationTitle"));
122
- Assert.assertEquals(JSONObject.NULL, json.get("notificationText"));
123
- Assert.assertEquals(JSONObject.NULL, json.get("notificationIconLarge"));
124
- Assert.assertEquals(JSONObject.NULL, json.get("notificationIconSmall"));
125
- }
126
-
127
- @Test
128
- public void testNullHashMapTemplateToJSONObject() {
129
- Config config = new Config();
130
- LocationTemplate tpl = new HashMapLocationTemplate((HashMapLocationTemplate)null);
131
- config.setTemplate(tpl);
132
-
133
- try {
134
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
135
- Assert.assertEquals(JSONObject.NULL, jConfig.get("postTemplate"));
136
- } catch (JSONException e) {
137
- Assert.fail(e.getMessage());
138
- }
139
- }
140
-
141
- @Test
142
- public void testEmptyHashMapTemplateToJSONObject() {
143
- Config config = new Config();
144
- HashMap map = new HashMap();
145
- LocationTemplate tpl = new HashMapLocationTemplate(map);
146
- config.setTemplate(tpl);
147
-
148
- try {
149
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
150
- Assert.assertEquals("{}", jConfig.get("postTemplate").toString());
151
- } catch (JSONException e) {
152
- Assert.fail(e.getMessage());
153
- }
154
- }
155
-
156
- @Test
157
- public void testHashMapTemplateToJSONObject() {
158
- Config config = new Config();
159
- HashMap map = new HashMap();
160
- map.put("foo", "bar");
161
- map.put("pretzels", 123);
162
- LocationTemplate tpl = new HashMapLocationTemplate(map);
163
- config.setTemplate(tpl);
164
-
165
- try {
166
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
167
- Assert.assertEquals("{\"foo\":\"bar\",\"pretzels\":123}", jConfig.get("postTemplate").toString());
168
- } catch (JSONException e) {
169
- Assert.fail(e.getMessage());
170
- }
171
- }
172
-
173
- @Test
174
- public void testNullArrayListLocationTemplateToJSONObject() {
175
- Config config = new Config();
176
- LocationTemplate tpl = new ArrayListLocationTemplate((ArrayListLocationTemplate)null);
177
- config.setTemplate(tpl);
178
-
179
- try {
180
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
181
- Assert.assertEquals(JSONObject.NULL, jConfig.get("postTemplate"));
182
- } catch (JSONException e) {
183
- Assert.fail(e.getMessage());
184
- }
185
- }
186
-
187
- @Test
188
- public void testEmptyArrayListLocationTemplateToJSONObject() {
189
- Config config = new Config();
190
- ArrayList list = new ArrayList();
191
- LocationTemplate tpl = new ArrayListLocationTemplate(list);
192
- config.setTemplate(tpl);
193
-
194
- try {
195
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
196
- Assert.assertEquals("[]", jConfig.get("postTemplate").toString());
197
- } catch (JSONException e) {
198
- Assert.fail(e.getMessage());
199
- }
200
- }
201
-
202
- @Test
203
- public void testArrayListLocationTemplateToJSONObject() {
204
- Config config = new Config();
205
- ArrayList list = new ArrayList();
206
- list.add("foo");
207
- list.add(123);
208
- list.add("foo");
209
-
210
- LocationTemplate tpl = new ArrayListLocationTemplate(list);
211
- config.setTemplate(tpl);
212
-
213
- try {
214
- JSONObject jConfig = ConfigMapper.toJSONObject(config);
215
- Assert.assertEquals("[\"foo\",123,\"foo\"]", jConfig.get("postTemplate").toString());
216
- } catch (JSONException e) {
217
- Assert.fail(e.getMessage());
218
- }
219
- }
220
- }
@@ -1,45 +0,0 @@
1
- package com.marianhello.bgloc;
2
-
3
- import androidx.test.platform.app.InstrumentationRegistry;
4
- import androidx.test.ext.junit.runners.AndroidJUnit4;
5
-
6
- import com.marianhello.bgloc.data.BackgroundLocation;
7
- import com.marianhello.bgloc.provider.TestLocationProviderFactory;
8
- import com.marianhello.bgloc.service.LocationServiceImpl;
9
-
10
- import org.junit.After;
11
- import org.junit.Ignore;
12
- import org.junit.Test;
13
- import org.junit.runner.RunWith;
14
-
15
- import java.util.concurrent.CountDownLatch;
16
-
17
- @RunWith(AndroidJUnit4.class)
18
- public class BackgroundGeolocationFacadeTest {
19
- @After
20
- public void tearDown() {
21
- LocationServiceImpl.setLocationProviderFactory(null);
22
- }
23
-
24
- @Ignore("Ignore test waiting for issue to be closed")
25
- @Test(timeout = 5000)
26
- public void testOnLocationChanged() throws InterruptedException {
27
- final CountDownLatch latch = new CountDownLatch(1);
28
- LocationServiceImpl.setLocationProviderFactory(new TestLocationProviderFactory());
29
-
30
- class FacadeDelegate extends TestPluginDelegate {
31
- @Override
32
- public void onLocationChanged(BackgroundLocation location) {
33
- latch.countDown();
34
- }
35
- }
36
-
37
- TestPluginDelegate delegate = new FacadeDelegate();
38
-
39
- final BackgroundGeolocationFacade facade = new BackgroundGeolocationFacade(
40
- InstrumentationRegistry.getContext(), delegate);
41
-
42
- facade.start();
43
- latch.await();
44
- }
45
- }