@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,225 +0,0 @@
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
- }
@@ -1,46 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
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
- }
@@ -1,92 +0,0 @@
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
- }
@@ -1,107 +0,0 @@
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
- }}
@@ -1,5 +0,0 @@
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
- }
@@ -1,82 +0,0 @@
1
- package com.marianhello.backgroundgeolocation;
2
-
3
- import com.marianhello.bgloc.data.ArrayListLocationTemplate;
4
- import com.marianhello.bgloc.data.BackgroundLocation;
5
- import com.marianhello.bgloc.data.LocationTemplate;
6
-
7
- import junit.framework.Assert;
8
-
9
- import org.json.JSONArray;
10
- import org.json.JSONException;
11
- import org.junit.Test;
12
-
13
- import java.util.ArrayList;
14
-
15
- /**
16
- * Created by finch on 15.12.2017.
17
- */
18
-
19
- public class ArrayListLocationTemplateTest {
20
- @Test
21
- public void testArrayTemplateToString() {
22
- ArrayList props = new ArrayList();
23
- props.add("foo");
24
- props.add("bar");
25
- props.add(123);
26
- props.add("foo");
27
- ArrayListLocationTemplate tpl = new ArrayListLocationTemplate(props);
28
-
29
- Assert.assertEquals("[\"foo\",\"bar\",123,\"foo\"]" , tpl.toString());
30
- }
31
-
32
- @Test
33
- public void testLocationToJSONArray() throws JSONException {
34
- BackgroundLocation location = new BackgroundLocation();
35
- location.setLocationId(11L);
36
- location.setProvider("test");
37
- location.setElapsedRealtimeNanos(2000000000L * 60 * 2);
38
- location.setAltitude(100);
39
- location.setLatitude(49);
40
- location.setLongitude(5);
41
- location.setLocationProvider(1);
42
- location.setAccuracy(105);
43
- location.setSpeed(50);
44
- location.setBearing(1);
45
-
46
- ArrayList props = new ArrayList();
47
- props.add("@id");
48
- props.add("@provider");
49
- props.add("@time");
50
- props.add("@altitude");
51
- props.add("@latitude");
52
- props.add("@longitude");
53
- props.add("foo");
54
- props.add("@locationProvider");
55
- props.add("@accuracy");
56
- props.add("@speed");
57
- props.add("@bearing");
58
- props.add(123);
59
-
60
- LocationTemplate tpl = new ArrayListLocationTemplate(props);
61
- JSONArray expected = (JSONArray) tpl.locationToJson(location);
62
-
63
- Assert.assertEquals(expected.get(0), location.getLocationId());
64
- Assert.assertEquals(expected.get(1), location.getProvider());
65
- Assert.assertEquals(expected.get(2), location.getTime());
66
- Assert.assertEquals(expected.get(3), location.getAltitude());
67
- Assert.assertEquals(expected.get(4), location.getLatitude());
68
- Assert.assertEquals(expected.get(5), location.getLongitude());
69
- Assert.assertEquals(expected.get(6), "foo");
70
- Assert.assertEquals(expected.get(7), location.getLocationProvider());
71
- Assert.assertEquals(expected.get(8), location.getAccuracy());
72
- Assert.assertEquals(expected.get(9), location.getSpeed());
73
- Assert.assertEquals(expected.get(10), location.getBearing());
74
- Assert.assertEquals(expected.get(11), 123);
75
- }
76
-
77
- @Test
78
- public void testNullToString() {
79
- ArrayListLocationTemplate tpl = new ArrayListLocationTemplate((ArrayList)null);
80
- Assert.assertEquals("null", tpl.toString());
81
- }
82
- }